Skip to content

AgentRunState

AgentRunState is the semantic step-level run state of the built-in step-driven ReAct strategy. It lives outside the workflow and is shared between AgentLoopState.run_state and the strategy (one instance, bridged by AGENT_ENTRY).

python
from amrita_core.builtins.agent.state import AgentRunState

state = AgentRunState()
state.begin_step("execute")

Fields

FieldTypeMeaning
step_indexintGlobal step counter (1-based)
current_phasestr | NoneThe active phase — a DAG node id (or "execute" in simple mode)
planlist[DAGNode] | NoneThe task DAG (None = no decomposition)
simple_modeboolTrue when the LLM decided to run directly
current_step_idstr | NoneId of the DAG node being executed
completed_step_idslist[str]Finished DAG node ids (dependency check)
plan_revisionintupdate_step revision counter
step_tool_signatureslist[str]Tool-call signatures in the current Step (stall window)
stall_injectedboolGive-up prompt injected (once per Step)
last_summaryStepSummary | NoneSubject-predicate summary of the previous Step
tokensTokenBudgetReal API token accounting
exec_finishedboolStrategy done calling tools → iteration loop ends

Methods

MethodPurpose
begin_step(phase)Enter a new Step: advance counter, reset per-Step state
begin_node(node)begin_step(node.id) + track current_step_id
record_tool_call(signature)Record a tool signature in the current Step
is_stalled(threshold)True when the last N signatures are identical
would_stall(signature, threshold)True if recording this signature would trip the detector (pre-execution cancel)
next_ready_node()Next DAG node in topological order (graphlib.TopologicalSorter; cyclic plans degrade gracefully)
complete_current_node()Mark the current node done
all_plan_done()True when every DAG node is completed

Apache 2.0 License