Skip to main content
Before copying a curl example, choose your Cloud region. For authenticated calls, it must be the same region as your key. The examples below use MIROBODY_API_BASE:
For SDK examples with a literal Global URL, use the matching China URL when your account is in China. See Regions. The Agent API runs two kinds of tools:
  1. Built-in server tools — the platform’s health-data tools. They run server-side; you never execute them. Their trace is reported, not delegated.
  2. Client function tools — tools you declare on the request. When the model wants one, the response hands off with a function_call output item; you execute it and continue the run.

Built-in server tools

The agent always has its platform toolset over the Subject’s data (same catalog as the Answers API):
  • query_health_data — search and aggregate the Subject’s records
  • list_family_members — resolve care-circle members the Subject is allowed to query
  • search_medical_evidence — search literature, guidelines/consensus, and registered trials (feeds citations)
  • read_source — read one search result by ref; arbitrary URL fetching is not supported
The /v1 agent’s domain tools are read-only. It also runs internal planning and analysis tools. Every server-tool run lands in the response object’s top-level tool_steps extension — never as an output item, which official SDKs would mis-parse — and in streaming as the response.mirobody_tool_call side-channel event.

Declaring client tools

Rules (violations are explicit 400s, never silently dropped):
Security note: the agent holds tools over the Subject’s health data. Subject isolation already limits every call to that developer’s own data, but treat your tool descriptions and results as part of the prompt surface — don’t feed untrusted third-party text through them without review.

The handoff

When the model calls your tool, the response completes with a function_call output item (status: "completed" — the response is done; the conversation is waiting on you):
In streaming, the same handoff arrives as a response.output_item.added → response.function_call_arguments.delta / .done → response.output_item.done event group (Streaming). Execute the tool, then continue the run in either of two ways:

Path 1 — stateful resume (previous_response_id)

Send only function_call_output items, referencing the handoff response. The server resumes the paused agent thread — no history resend:
Requirements: outputs must cover exactly the pending call_ids (parallel calls → one function_call_output each); you may not mix message items into a resume; a handoff can be resumed once (a duplicate resume fails loudly). The handoff response must have been stored (store=true, the default).

Path 2 — stateless full replay

What openai-agents does by default: resend the entire item transcript in input — including the function_call / function_call_output pairs — with no previous_response_id:
The pairs are reconstructed as conversation history and the run continues as a fresh turn. Works with store=false end to end.

End-to-end with openai-agents

The SDK handles the whole loop — declaration, handoff, execution, replay:
Every agents-SDK agent that touches Mirobody tools must pass the Subject via model_settings=ModelSettings(extra_body={"user": ...}). Without it, the run reads the account-default Subject, not the user you meant.
The model reads the Subject’s real glucose data with built-in server tools, then hands off to your book_appointment — the SDK executes it locally and replays the transcript automatically.

Continuation errors

See also