Source:
docs/manual/agent-workflow.mdThis page is generated by
site/scripts/sync-manual-docs.mjs.
Agent Workflow
The agent workflow is Cruvero's core execution loop. It runs as a Temporal workflow that repeatedly observes context, asks an LLM for a decision, executes the chosen tool, and records the result — until the agent halts or reaches its step limit. This document covers the execution sequence, control signals, approval flow, and state management.
Source: internal/agent/workflow.go
Execution Sequence
Lifecycle
- Load tool registry (immutable reference).
- Load memory (episodic/semantic/procedural) if not present.
- Ingest initial prompt to memory.
- Loop: decide -> approve (if needed) -> tool -> observe -> optional metacognitive/deadline checks -> record.
Metacognitive Monitoring
Metacognitive monitoring guards against low-progress loops and stale strategies.
When it runs:
- Controlled by
CRUVERO_METACOGNITIVE_ENABLEDandCRUVERO_METACOGNITIVE_CHECK_INTERVAL. - Evaluates repeated tool hashes, progress deltas, entropy, and goal similarity snapshots.
Backpressure actions:
reflect: inject a reflection note to force strategy reconsideration.escalate_model: route the next decision toCRUVERO_METACOGNITIVE_ESCALATION_MODELwhen set.reset_context: clear working counters/context slices that may be anchoring bad behavior.pivot_strategy: block repetitive tool hashes and force a different path.human_escalation: request explicit operator input/approval.
Example:
- If a run repeats the same tool/arguments around the configured repetition threshold, the workflow can pivot strategy or escalate to a different model instead of continuing a loop.
Temporal Reasoning
Temporal reasoning makes the run deadline-aware.
Behavior:
- Uses soft and hard deadlines from run-time constraints.
- Computes pressure levels:
relaxed,moderate,high,critical. - Under high/critical pressure, the workflow can switch to
CRUVERO_DEFAULT_FAST_MODEL. - At hard deadline, behavior follows
CRUVERO_DEADLINE_ACTION(escalateorhalt). - Time context is injected into decision prompts so tool/model choices reflect remaining time.
CLI/runtime inputs:
cmd/run --soft-deadline ... --hard-deadline ... --fast-model ...CRUVERO_TEMPORAL_REASONING_ENABLEDCRUVERO_DEFAULT_FAST_MODELCRUVERO_DEADLINE_ACTION
Decision Records
Each step creates a DecisionRecord containing:
input_hash(deterministic hash of prompt + step + state)- prompt/state hashes and tool schema hash
- decision metadata (action, tool, override)
- latency/model fields
- usage and cost estimates
Tool Routing (Plain Language)
Before the final decision, routing can suggest a likely tool based on request context. The LLM still produces final action and args.
Approvals
- If
require_approvalis true, workflow waits on signalapproval. - Pending approvals are exposed via query
pending_approvals. - Approval requests are identified by
step-<index>.
Live Control
Signals on channel control support:
pause,resume,step(single-step then pause)
Continue-as-New
- Controlled by
AgentConfig.ContinueAsNewStepsandContinueAsNewStateBytes. - Keeps workflow history bounded for long-lived runs.
Replay and Overrides
DecisionOverridescan replace LLM output per step.cmd/replaysupports--decision-overridesfor counterfactual analysis.
Tracing and Provenance
- Each step stores a causal trace in
agent_traces. - Optional provenance DAG persistence (when enabled) stores influence nodes/edges.
- Query via
cmd/query --query causal_trace,cmd/trace-query, andcmd/provenance-query.