Context Handling
Agent Actions builds prompt context differently depending on execution mode.
Mode Differences
| Mode | Context Structure |
|---|---|
| Online | Input data under source namespace |
| Batch | Input data at root level |
Online Mode
{
"source": {
"page_content": "Document text...",
"url": "https://example.com"
},
"seed": { "exam_syllabus": {...} }
}
Analyze: {{ source.page_content }}
Batch Mode
{
"page_content": "Document text...",
"url": "https://example.com",
"seed": { "exam_syllabus": {...} }
}
Analyze: {{ page_content }}
warning
The same template can fail in different modes. {{ source.field }} works in online but fails in batch.
Mode-Agnostic Templates
{% if source is defined %}
Content: {{ source.page_content }}
{% else %}
Content: {{ page_content }}
{% endif %}
Context Variables
| Variable | Description | Available In |
|---|---|---|
source | Input record (wrapped) | Online only |
seed | Static seed data | Both modes |
{action_name} | Previous action output | Both modes |
| Root fields | Input record fields | Batch only |
Context Scope
Control data visibility with context_scope:
actions:
- name: my_action
context_scope:
observe:
- seed.exam_syllabus
- prev_action.result
drop:
- source.sensitive_field
Best Practices
- Choose one mode per workflow - Don't switch modes mid-workflow
- Match template to mode - Use
source.*for online, root fields for batch - Use seed data for static content - Works identically in both modes
- Analyze schemas - Run
agac schema -a my_workflowto check field dependencies
See Also
- Run Modes - Batch vs online execution
- Context Scope - Field visibility configuration