- Update all factor file names to use two-digit numbering (e.g., factor-01, factor-02) - Update all internal links to reflect new file naming convention - Update image references to match new naming pattern - Maintain consistent navigation links across all factor documents This change improves file organization and makes the documentation structure more maintainable.
2.7 KiB
5. Unify execution state and business state
Even outside the AI world, many infrastructure systems try to separate "execution state" from "business state". For AI apps, this might involve complex abstractions to track things like current step, next step, waiting status, retry counts, etc. This separation creates complexity that may be worthwhile, but may be overkill for your use case.
As always, it's up to you to decide what's right for your application. But don't think you have to manage them separately.
More clearly:
- Execution state: current step, next step, waiting status, retry counts, etc.
- Business state: What's happened in the agent workflow so far (e.g. list of OpenAI messages, list of tool calls and results, etc.)
If possible, SIMPLIFY - unify these as much as possible.
In reality, you can engineer your application so that you can infer all execution state from the context window. In many cases, execution state (current step, waiting status, etc.) is just metadata about what has happened so far.
You may have things that can't go in the context window, like session ids, password contexts, etc, but your goal should be to minimize those things. By embracing factor 3 you can control what actually goes into the LLM
This approach has several benefits:
- Simplicity: One source of truth for all state
- Serialization: The thread is trivially serializable/deserializable
- Debugging: The entire history is visible in one place
- Flexibility: Easy to add new state by just adding new event types
- Recovery: Can resume from any point by just loading the thread
- Forking: Can fork the thread at any point by copying some subset of the thread into a new context / state ID
- Human Interfaces and Observability: Trivial to convert a thread into a human-readable markdown or a rich Web app UI
