When to use multi-agent orchestration
Use multi-agent orchestration when a task breaks cleanly into well-bounded subtasks, or when different subtasks require different agent configurations. Common use cases include:- Processing independent sources or subtasks in parallel and having the coordinator agent synthesize the final output.
- Delegating specialized work such as code review or source retrieval to agents equipped with dedicated tools or skills.
- Running multiple instances of the same agent configuration to handle separate inputs concurrently.
- Inspecting or auditing the execution trace of each subtask independently.
Coordinator agent and child threads
When you create a session, the platform creates a coordinator thread. It serves as the session’s default entry point and handles user input submitted through session-level endpoints. When the coordinator agent decides to delegate work, the platform creates child threads inside the same session. Each child thread executes the subtask assigned by the coordinator agent and returns its result to the coordinator agent.
The coordinator thread and child threads belong to the same session, but each thread maintains its own status, event history, and live event stream.
Sharing an execution environment does not mean sharing the full model context.
A coordinator agent can spawn child threads, whereas child threads cannot spawn further nested threads.
Configure delegatable agents
When creating or updating a coordinator agent, declare the agents it can delegate to inmultiagent.agents.
Use type to specify the reference source:
type: "agent": References another existing agent. Setidto that agent’s ID;versionis optional, and if omitted, the platform pins its latest version at write time.type: "self": References the coordinator agent itself so child threads reuse the coordinator agent’s currently pinned version and configuration;idis not required.
agents must contain 1–20 entries. On update, pass agents: [] to clear the delegation roster.
Referencing the same agent more than once, using duplicate display names, referencing an archived agent, or referencing an agent that itself has multiagent configured fails at write time.
Updating a referenced agent afterward does not alter an already saved delegation configuration.
To have the coordinator agent use a newer version of a referenced agent, update the coordinator agent to generate a new immutable version.
Create a coordinator agent
The example below creates a coordinator agent and pins its roster of delegatable agents at creation time. This request neither spawns child threads nor creates the referenced agents: replaceagent_researcher with an agent ID that already exists in your project.
The self entry in the roster allows the coordinator agent to spawn child threads that reuse its own pinned version and configuration.
id in the response is the coordinator agent’s ID, which you pass when creating a session.
multiagent.agents in the response shows the pinned agent versions; because self resolves to the coordinator agent itself at write time, the list also includes an entry pointing to the coordinator agent’s own ID and version.
The snippet below shows only the fields needed for the rest of this guide—refer to the OpenAPI specification for the full response schema:
id for creating a session next:
Create and run a session
Create a session
Create a session with the coordinator agent from the previous step and an execution environment. Replaceenv_xxx with the ID of an actual execution environment.
id in the response is the session ID used to send tasks and query threads:
Send a task
Send auser.message event through the session events endpoint.
Pass message content as a content array where each content block declares its own type.
spawn_subagent, the platform creates the child thread in the same session and starts execution.
Synchronous and asynchronous delegation
You guide delegation through agent configuration and instructions rather than supplying tool arguments directly.spawn_subagent is a runtime tool invoked by the model, not a REST API endpoint called by clients.
If your client needs deterministic control over subtask inputs and execution order, orchestrate multiple session calls from your client instead of using multi-agent delegation.
An example spawn_subagent tool input looks like this:
agent_typeis required with no default value—it specifies the display name of an agent in the delegation roster.descriptionis a short label identifying the subtask.promptprovides the full instructions needed for the child thread to carry out the subtask.run_in_background: falseruns the child thread synchronously and is the default behavior.run_in_background: trueruns the child thread asynchronously.
Synchronous delegation
Synchronous delegation waits until the child thread returns a report, entersidle, or terminates before the coordinator agent resumes execution.
Use synchronous delegation when subsequent steps depend directly on the child thread’s output.
Asynchronous delegation
Asynchronous delegation returns immediately once the child thread is created and starts running. When the child thread finishes a turn, it delivers its report back to the coordinator agent, which can continue doing other work in the meantime or wait for messages. The tool result for asynchronous delegation is a text message containing the child thread ID and follow-up instructions:idle and is not deleted automatically; the coordinator agent can call delete_subagent to terminate it, transitioning the thread status to terminated.
If follow-up work is needed on the same subtask, the coordinator agent can reuse the child thread by sending further messages with send_message. Clients cannot send messages directly to child threads.
Send messages between agents
All inter-agent messages in Kimi Hosted Agents are routed through the coordinator thread. The coordinator thread can send a message to a specific child thread or broadcast to all child threads, whereas child threads can only send results or questions back to the coordinator thread. Child threads cannot communicate directly with each other or send messages across sessions.Send messages: send_message
The coordinator agent can message a specific child thread or broadcast to all child threads:
agent_id to all:
Wait for messages: wait_for_message
The coordinator agent—or an asynchronous child thread participating in message-based collaboration—can call wait_for_message to wait for incoming messages:
from_session_thread_id) and source agent display name (from_agent_name) from the agent.thread_message_received event payload.
To inspect the child thread’s full execution trace, read the thread’s event history rather than relying on the wait_for_message return text.
Shared resources and context isolation
Agents, sessions, and threads manage configuration at different scopes:
Each child thread runs with the pinned version and configuration of its selected agent.
Session-bound resources such as files, vaults, and memory stores are managed through session configuration; see Create a Session for how to bind them.
Session-level
agent_overrides apply only to the current session and do not modify any stored agent resource. Setting agent_overrides.roster when creating a session replaces the delegation roster and pins the referenced versions for this session.
Other agent_overrides fields (such as model, system, tools, mcp_servers, skills, and plugins) take effect only on the coordinator thread and are not propagated to child threads, including self entries. Each child thread runs the agent version pinned in the effective roster for the session.
Observe threads and events
After sending a task, you can observe overall progress on the coordinator thread through the session-level event stream. To inspect detailed activity on a child thread, first list the threads in the session and then query the target thread using itsid.
List threads in a session
id from the list response for subsequent thread queries.
The coordinator thread has no parent_thread_id, whereas child threads point to their parent thread via parent_thread_id.
If the response includes next_page_token, fetch subsequent pages rather than assuming the current page contains all threads.
Get thread details
Set$THREAD_ID to the id of the target thread from the thread list:
status field in the response indicates whether the thread is still running:
Read thread event history
session.thread_created is recorded only in the coordinator thread’s history—observe it through the session-level event stream (coordinator thread), as it does not appear in the child thread’s own event history.
The response above highlights only the event fields relevant to multi-agent orchestration.
For the full set of event types, fields, and pagination rules, see Event Stream.
Subscribe to live thread events
id: line in each SSE frame is a numeric resume cursor that lets you resume streaming after a disconnect; see Event Stream for details.
Use session_thread_id in the event payload to identify which thread an event belongs to.
A thread cursor is valid only for that specific thread’s event stream and cannot be used across other threads or sessions.
Archive a child thread
You can archive a child thread to terminate it and cancel any in-flight execution without waiting for it to becomeidle. The coordinator thread cannot be archived separately; archive the session instead.
204 No Content on success.
Archiving a thread does not delete its event history.
Event sequence of a delegation
A typical asynchronous delegation produces events in roughly the following order:Best practices
Define clear task boundaries for child threads
Inprompt, state the inputs, expected outputs, success criteria, and what supporting evidence to retain.
For example:
Configure only the agents you need
Only add agents to the roster if the coordinator agent genuinely needs to delegate to them. Adding unnecessary agents gives the model more candidates to choose from and increases the effort required to maintain the roster.Standardize the report format
Instruct child threads to return reports using a consistent structure:Audit with thread-level event streams
Do not rely solely on the coordinator agent’s final summary. When debugging or auditing, list the threads in the session and inspect each target child thread’s event history and live event stream independently.Next steps
Configure agents and delegation
Configure agents, tools, and multi-agent delegation rosters.
Start a multi-agent session
Create a session and submit task inputs.
Inspect thread events
Read event history, subscribe to SSE streams, and resume from cursors.
Explore the investment research team design
See the full design of the official multi-agent investment research team.