Build conversational workflows that maintain context across multiple executions, creating truly intelligent and natural interactions.
Workflow History enables your Agno workflows to remember and reference previous conversations, transforming isolated executions into continuous, context-aware interactions.Instead of starting fresh each time, with Workflow History you can:
Build on previous interactions - Reference the context of past interactions
Avoid repetitive questions - Avoid requesting previously provided information
Maintain context continuity - Create a conversational experience
Learn from patterns - Analyze historical data to make better decisions
Note that this feature is different from add_history_to_context.
This does not add the history of a particular agent or team, but the full workflow history to either all or some steps.
When workflow history is enabled, previous messages are automatically injected into agent/team inputs as structured context:
<workflow_history_context>[run-1]input: Create content about AI in healthcareresponse: # AI in Healthcare: Transforming Patient Care...[run-2] input: Make it more family-focusedresponse: # AI in Family Healthcare: A Parent's Guide...</workflow_history_context>Your current input goes here...
Along with this, in using Steps with custom functions, you can access this history in the following ways:
As a formatted context string as shown above
In a structured format as well for more control
[ (<workflow input from run 1>)(<workflow output from run 1>), (<workflow input from run 2>)(<workflow output from run 2>),]
A database is required to use Workflow history. Runs across different executions will be persisted there.
Example-
def custom_function(step_input: StepInput) -> StepOutput: # Option 1: Structured data for analysis history_tuples = step_input.get_workflow_history(num_runs=3) for user_input, workflow_output in history_tuples: # Process each conversation turn # Option 2: Formatted context for agents context_string = step_input.get_workflow_history_context(num_runs=3) return StepOutput(content="Analysis complete")
You can use these helper functions to access the history:
By default, all available history is included (no limit). It is recommended to use a fixed history run limit to avoid bloating the LLM context window.You can control this at both levels:
# Workflow-level: limit history for all stepsworkflow = Workflow( add_workflow_history_to_steps=True, num_history_runs=5 # Only last 5 runs)# Step-level: override for specific stepsStep("Analysis", agent=analysis_agent, add_workflow_history=True, num_history_runs=3 # Only last 3 runs for this step)