How Dagu manages agent context, failover and recovery
Dagu’s Agent DAG runtime treats the conversation as persistent execution state, linking AI operating costs and recovery to the transcript. Each decision receives a rebuilt system prompt containing task statuses and collected human answers, alongside conversation history. Observation limits bound incoming results, while context management replaces older tool results with compact summaries that preserve tool-calling structure.
Model requests follow an ordered fallback chain after applicable retries. Context overflow triggers transcript compaction and another attempt with the current model before failover, when observation aging is enabled. Successful fallback choices remain active within the process, but recovery starts again with the configured primary. Action batches are validated before execution, and sibling actions cannot consume each other’s outputs from the same turn.
After each decision, Dagu saves task state, action counts, turn usage and the conversation. Human-task suspension and failed-run retries resume that saved state rather than replaying successful actions, using the workflow definition captured when the run began. Token usage is recorded per decision and aggregated for the run, with costs included when providers report them. Declared secrets are masked before requests leave for providers, but stored transcripts retain resolved values. Access to run data therefore also exposes any secrets recorded there.