Body
Payload to create a new conversation.
Contains an Agent configuration along with conversation-specific options.
Main agent implementation for OpenHands.
The Agent class provides the core functionality for running AI agents that can interact with tools, process messages, and execute actions. It inherits from AgentBase and implements the agent execution logic.
Example: >>> from openhands.sdk import LLM, Agent, Tool >>> llm = LLM(model="claude-sonnet-4-20250514", api_key=SecretStr("key")) >>> tools = [Tool(name="BashTool"), Tool(name="FileEditorTool")] >>> agent = Agent(llm=llm, tools=tools)
Working directory for agent operations and tool execution
Optional conversation ID. If not provided, a random UUID will be generated.
Controls when the conversation will prompt the user before continuing. Defaults to never.
- AlwaysConfirm
- ConfirmRisky
- NeverConfirm
Initial message to pass to the LLM Payload to send a message to the agent.
This is a simplified version of openhands.sdk.Message.
If set, the max number of iterations the agent will run before stopping. This is useful to prevent infinite loops.
x >= 1If true, the conversation will use stuck detection to prevent infinite loops.
Secrets available in the conversation
Response
Successful Response
Information about a conversation running locally without a Runtime sandbox.
Unique conversation ID
The agent running in the conversation. This is persisted to allow resuming conversations and check agent configuration to handle e.g., tool changes, LLM changes, etc.
Local workspace implementation that operates on the host filesystem.
LocalWorkspace provides direct access to the local filesystem and command execution environment. It's suitable for development and testing scenarios where the agent should operate directly on the host system.
Example: >>> workspace = LocalWorkspace(working_dir="/path/to/project") >>> with workspace: ... result = workspace.execute_command("ls -la") ... content = workspace.read_file("README.md")
- LocalWorkspace
- RemoteWorkspace
Directory for persisting conversation state and events. If None, conversation will not be persisted.
Maximum number of iterations the agent can perform in a single run.
x > 0Whether to enable stuck detection for the agent.
Enum representing the current execution state of the conversation.
idle, running, paused, waiting_for_confirmation, finished, error, stuck - AlwaysConfirm
- ConfirmRisky
- NeverConfirm
List of activated knowledge skills name
Conversation statistics for tracking LLM metrics
Registry for handling secrets and sensitive data
User-defined title for the conversation
A snapshot of metrics at a point in time.
Does not include lists of individual costs, latencies, or token usages.

