Skip to main content
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. The model uses the shared OPENAI_MODEL, OPENAI_BASE_URL, and optional OPENAI_API_KEY process environment. Configure your server’s model ID and compatible API URL; no vendor or model is selected by default. Follow Configure a model for local, CI, and deployment setup. 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 an optional token_policy to observe usage, enforce budgets, or choose context reductions per agent. Policies are absent by default and can be disabled or overridden in trusted invocation code. 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
Nodes can be callables, agents, nested graphs, joins, discovered resources, or supported native nodes. Harnest rejects unknown edges, duplicates, and unreachable nodes before execution.

Structured input and output

Pass Pydantic classes from harnest.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
Your code then owns native routing, state, checkpoints, middleware or plugins, and capability wiring. Harnest keeps the neutral server, sessions, auth, approvals, and telemetry.