Skip to main content
Semantic memory alone is not enough for long-running agents. Explicit state and planner history make behavior testable and auditable.

Mental model

  • Variables hold explicit machine-readable state.
  • Goals define outcomes and priority.
  • Actions and cycles record planner decisions over time.
  • Logs and snapshots make behavior inspectable.

Minimal implementation example

04-state-and-goals.py
client.control.set_variable({
    "run_id": run_id,
    "name": "resolution_stage",
    "value_json": '{"stage":"needs-billing-review"}',
    "source": "reasoning",
})

goal = client.control.add_goal({
    "run_id": run_id,
    "description": "Resolve ticket with grounded invoice explanation",
    "priority": "high",
})

client.control.submit_action({
    "run_id": run_id,
    "agent_id": "support-agent",
    "action_type": "retrieve",
    "action_json": '{"query":"collect invoice discrepancy details"}',
})

cycle = client.control.run_cycle({
    "run_id": run_id,
    "agent_id": "support-agent",
    "candidates": [{
        "action_type": "reason",
        "action_json": '{"prompt":"choose safest next response step"}',
        "score": 0.89,
        "rationale": "preserve accuracy before response",
    }],
})

print(goal.get("id"), cycle.get("cycle_number"))

Failure modes and troubleshooting

SymptomRoot causeFix
State conflictsWrites spread across multiple runsKeep deterministic run identity
Goal sprawlNo parent/priority disciplineDefine team goal policy
Opaque behaviorAction/cycle logs not reviewedAdd routine log checks in dev and ops

Next steps