Skip to main content
The Agent class is the core primitive of OpenHarness. An agent wraps a language model, a set of tools, and a multi-step execution loop into a stateless executor that you can run() with a message history and new input.

Creating an Agent

Running an Agent

agent.run() is an async generator that takes a message history and new input, and yields a stream of typed events as the agent works. The agent is stateless — it doesn’t accumulate messages internally. You pass the conversation history in and get the updated history back in the done event.
This makes it easy to build multi-turn interactions — just pass the messages from the previous done event into the next run() call. It also means you have full control over the conversation history: you can inspect it, modify it, or share it between agents.

Events

The full set of events emitted by run():

Configuration

Multi-Turn Conversations

Since the agent is stateless, multi-turn is achieved by passing the updated messages back in:
For automatic history management, compaction, and retry, use a Session or Conversation.

Cleanup

If the agent uses MCP servers or background subagents, call close() when done: