Overview
The State API provides theAgentState class for managing agent execution state, conversation history, and context. Each agent maintains its own state throughout its lifecycle.
AgentState
Manages the complete state of an agent including messages, iteration count, and execution metadata.Constructor
str
default:"'Strix Agent'"
Human-readable name for the agent
int
default:"300"
Maximum number of iterations allowed before stopping
Properties
Identity
str
Unique identifier auto-generated as “agent_” + 8 random hex characters
str
default:"'Strix Agent'"
Agent display name
str | None
default:"None"
Parent agent ID if this is a sub-agent
Sandbox Information
str | None
default:"None"
Docker container ID for the sandbox environment
str | None
default:"None"
Authentication token for sandbox API
dict[str, Any] | None
default:"None"
Complete sandbox information including ports and URLs
Execution State
str
default:"''"
Current task description
int
default:"0"
Current iteration number
int
default:"300"
Maximum iterations allowed
bool
default:"False"
Whether execution is completed
bool
default:"False"
Whether stop has been requested
bool
default:"False"
Whether agent is waiting for input
bool
default:"False"
Whether LLM requests are failing
dict[str, Any] | None
default:"None"
Final result when completed
Data Storage
list[dict[str, Any]]
default:"[]"
Conversation history (role, content, thinking_blocks)
dict[str, Any]
default:"{}"
Additional context storage
list[dict[str, Any]]
default:"[]"
Record of all actions taken with timestamps
list[dict[str, Any]]
default:"[]"
Observations recorded during execution
list[str]
default:"[]"
Error messages
Timestamps
str
ISO 8601 timestamp when state was created
str
ISO 8601 timestamp of last update
datetime | None
default:"None"
When agent entered waiting state
Methods
Message Management
add_message
str
required
Message role: “user” or “assistant”
Any
required
Message content (string or structured content)
list[dict[str, Any]] | None
Optional thinking blocks from reasoning models
get_conversation_history
list[dict[str, Any]]
List of message dictionaries
Iteration Management
increment_iteration
has_reached_max_iterations
bool
True if iteration >= max_iterations
is_approaching_max_iterations
float
default:"0.85"
Percentage threshold (0.0 to 1.0)
bool
True if past threshold
Execution Control
set_completed
dict[str, Any] | None
Final result data
request_stop
should_stop
bool
True if stop_requested, completed, or max iterations reached
Waiting State
enter_waiting_state
bool
default:"False"
Whether entering wait due to LLM failure
resume_from_waiting
str | None
Optional new task to set
is_waiting_for_input
bool
True if waiting
has_waiting_timeout
bool
True if timeout reached
Data Recording
add_action
dict[str, Any]
required
Action data to record
add_observation
dict[str, Any]
required
Observation data
add_error
str
required
Error message
Context Management
update_context
str
required
Context key
Any
required
Context value
Summary
get_execution_summary
dict[str, Any]
Dictionary containing:
- agent_id, agent_name, parent_id
- sandbox_id, sandbox_info
- task, iteration, max_iterations
- completed, final_result
- start_time, last_updated
- total_actions, total_observations, total_errors
- has_errors, max_iterations_reached
has_empty_last_messages
int
default:"3"
Number of messages to check
bool
True if last N messages are empty