Agent State, Memory, and Planning
Agent state is the structured record of what has happened and what remains. Short-term state may include current plan, tool results, and unresolved tasks. Long-term memory may store user preferences or durable facts, but should have consent, provenance, expiration, and deletion controls. Do not write every conversation detail into permanent memory.
Planning can be useful for multi-step tasks, but plans are hypotheses rather than proof. Validate each step, re-check current facts before irreversible actions, and detect loops. Memory retrieval should be scoped to the current user and purpose, and sensitive information needs special handling.
Typed task state
const taskState = {
goal: "Prepare a course outline",
steps: [
{ id: "research", status: "completed" },
{ id: "draft", status: "in_progress" },
{ id: "review", status: "pending" }
],
attempts: 1,
maxAttempts: 3
};💡 Explicit state makes retries and resumability visible. In production, persist state durably, validate transitions, and prevent the model from editing privileged fields such as user identity or approval status.
Key Takeaways
- Separate short-term state from long-term memory.
- Track provenance and deletion requirements for memory.
- Treat model-generated plans as proposals to validate.
Knowledge Check
Why should agent state be structured and validated?