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:
Takes a blog post
Creates a summary
Generates social media posts from both the full post and the summary
Step 1: Create Your First Task
Create a new action
Add a "Run Prompt" task
Name it "Generate Summary"
Set the task variable name to "summary"
Enter this prompt:
Create a concise 2-paragraph summary of this blog post:
{{WholeDocument}}
Step 2: Add a Social Post Generator
Add a "Stream Prompt" task
Name it "Generate LinkedIn Post"
Set the task variable name to "linkedin_post"
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
Add a "Stream Prompt" task
Name it "Generate Twitter Thread"
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:
Add a "Pause: Review" task after the summary generation
Add an "Ask for Input" task at the start to specify the target audience
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.