How to use `get_state()` for workflow awareness
mainThe get_state() tool is the primary mechanism for the agent to understand the current context. Because the CLI does not inject state automatically, you must call it to learn about the environment.
When to call get_state()
- At the start of every session: This is the mandatory first action to detect active scenarios or existing work on disk.
- After completing tasks: To refresh the list of available or blocked tasks.
- When status is requested: If a user asks "where are we?" or "what is the progress?".
- When external changes occur: If the user manually edits files or another session has run.
- After context compaction: If the conversation history becomes too large and you lose track of the current scenario or stage.
Interpreting the response
get_state() returns one of three states:
- Active scenario:
hasActiveScenario: true. UsetaskProgress.availableTasksto find the next step and checkstaleTaskWarnings. - Existing scenarios on disk:
hasActiveScenario: falsebutexistingScenariosis present. Useresume_scenariowith the appropriate ID to pick up where a previous session left off. - No scenarios: A fresh start. Use
get_scenarios()to match the user's request to a known workflow.