agent.py exports the configured root_agent. In managed mode this is an Agent or portable Graph; in advanced mode it wraps a native ADK or LangGraph target with Agent.advanced(...).
See Python imports for the public modules that group agent, model, tool, and runtime APIs.
Managed agent
The concise form builds a native agent for the selected framework:agent.py
instructions.md beside agent.py is required. It is the default managed prompt and remains bundle metadata for graphs and advanced targets.
Set OPENAI_MODEL, OPENAI_BASE_URL, and, if required, OPENAI_API_KEY. No model or endpoint is selected by default. See Configure a model.
history="session" is the default and includes earlier user and assistant turns from the same Harnest session. Use history="turn" for an isolated model call. Do not duplicate the conversation transcript in graph state.
Use token_policy to observe usage, enforce budgets, or reduce context per agent. See Token utilisation.
Portable graph
Use a graph for deterministic routing, parallel branches, joins, agent nodes, or a topology that should lower to either framework:agent.py
Structured input and output
Pass Pydantic classes fromharnest.models.* as input_schema or output_schema. Harnest applies them to JSON, SSE, WebSocket, and OpenAPI. Add an explicit FrameworkMetadata[...] field only when you need native turn metadata.
Advanced target
Use advanced mode only when the portable API cannot express required native behavior:agent.py
API reference
Reference:harnest.model.