-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Summary
Investigate adding a context_mode option to control what context gets passed between agents in a workflow.
Background
From a user question:
My scenario involves a deterministic sequential flow with multiple agents, so I'm using the Agent framework's sequential workflow. In my case, I don't need to pass the whole context to each agent in the workflow; I only want each agent to receive the final output from the previous one as input. From what I understand, the default behavior is to pass the entire context. How can I adjust this?
Current Workaround
Today, users need to create a custom executor that transforms the conversation between agents:
class LastOutputOnlyExecutor(Executor):
@handler
async def transform(
self,
messages: list[ChatMessage],
ctx: WorkflowContext[list[ChatMessage]]
) -> None:
# Extract only the last assistant message
last_assistant = [m for m in messages if m.role == "assistant"][-1:]
await ctx.send_message(last_assistant)Then build the flow like:
workflow = SequentialBuilder().participants([
agent1,
LastOutputOnlyExecutor(id="filter-1"),
agent2,
LastOutputOnlyExecutor(id="filter-2"),
agent3,
]).build()Proposed Solution
Investigate adding a context_mode parameter to reduce verbosity. Possible modes:
full(default) - pass entire conversation contextlast_output- pass only the last assistant messagelast_n- pass last N messages- Custom filter function
Scope
This feature should be evaluated for all orchestration patterns, not just sequential:
- Sequential workflows
- Concurrent workflows
- Group chat
- Other orchestration patterns
Metadata
Metadata
Assignees
Labels
Type
Projects
Status