Understanding Context Flow in Actions

Context flow is one of the most powerful features of Chibi Actions. This tutorial will teach you how to control what information passes between tasks, allowing you to build more sophisticated and precise actions.

What You'll Learn

In this tutorial, you'll learn how to:

  • Pass information between tasks using task variables

  • Control what context each task receives

  • Use custom sources to override default context flow

  • Combine multiple pieces of context in your tasks

Understanding Task Variables and Context Flow

Think of tasks in an action as workers on an assembly line. Each worker (task) can:

  • Receive material (context) from the previous worker

  • Process that material in some way

  • Pass the processed material to the next worker

  • Create new materials to share with other workers

Let's build a practical example that will demonstrate these concepts clearly.

Practice Example: Creating a Blog Post Summary Action

We'll create an action that:

  1. Takes a blog post

  2. Creates a summary

  3. Generates social media posts from both the full post and the summary

Step 1: Create Your First Task

  1. Create a new action

  2. Add a "Run Prompt" task

  3. Name it "Generate Summary"

  4. Set the task variable name to "summary"

  5. Enter this prompt:

Create a concise 2-paragraph summary of this blog post:

{{WholeDocument}}

Step 2: Add a Social Post Generator

  1. Add a "Stream Prompt" task

  2. Name it "Generate LinkedIn Post"

  3. Set the task variable name to "linkedin_post"

  4. Enter this prompt:

Create an engaging LinkedIn post about this content. Include relevant hashtags.

Original Post:
{{WholeDocument}}

Summary:
{{summary}}

Step 3: Add the Final Task

  1. Add a "Stream Prompt" task

  2. Name it "Generate Twitter Thread"

  3. Enter this prompt:

Create a thread of 3-5 tweets about this content. Start each tweet with a number and period (1., 2., etc.)

LinkedIn Post:
{{linkedin_post}}

Summary:
{{summary}}

Understanding What's Happening

Let's break down how context flows through this action:

1. First Task (Generate Summary)

  • Receives: The whole document via {{WholeDocument}}

  • Processes: Creates a summary

  • Stores: Result in the "summary" variable

2. Second Task (Generate LinkedIn Post)

  • Uses: Both original post and summary in prompt

  • Processes: Creates a LinkedIn post

  • Stores: Result in the "linkedin_post" variable

3. Final Task (Generate Twitter Thread)

  • Could have received: The LinkedIn post (default context flow)

  • Uses: Both the LinkedIn post and summary in prompt

  • Processes: Creates a Twitter thread

  • Streams: Result directly into the document

Key Concepts to Remember

1. Task Variable Names

  • Always name your task variables descriptively

  • Use underscores for multi-word names (e.g., "linkedin_post")

  • Variables are available to all subsequent tasks

2. Default Context Flow

  • Previous task variables are available to subsequent tasks

Tips for Success

  • Plan your context flow before building complex actions

  • Use descriptive task variable names to keep track of your context

  • Test your action with small pieces of content first

  • Use the "Pause: Review" task while testing to see what content is flowing between tasks

Practice Exercise

Try modifying the action we created:

  1. Add a "Pause: Review" task after the summary generation

  2. Add an "Ask for Input" task at the start to specify the target audience

  3. Use that audience information in your prompts via the task variable

This will help you understand how context flows and how to control it effectively.

Common Mistakes to Avoid

1. Forgetting to Name Variables

  • Default names (FromTask:1, etc.) are harder to work with

  • Makes actions harder to maintain and modify

2. Not Using Custom Sources When Needed

  • Don't rely on just the previous task's output if you need more context

  • Combine multiple pieces of context when it makes sense

3. Over-Complicating Context Flow

  • Keep it simple when possible

  • Only pass the context that's actually needed

Remember: Every task can access any variable created by previous tasks, but you need to explicitly use those variables either in your prompt or custom source to access them.

Was this helpful?