Appearance
Compose agents with a concierge
Concierge answers general questions itself and sends every weather question to the weather agent. The connection is one file. The Agent SDK turns the target agent's MCP endpoint into tools the concierge can call.
Use this example when two agents are useful on their own and one should delegate a narrow class of work to the other.
Delegate through a peer MCP connection
Concierge has no domain tool of its own. Its capability comes from a peer MCP connection:
ts
export default defineConnection({
agent: "weather-agent",
description:
"The weather-agent peer: delegate weather questions with ask; it runs its own tools (live Open-Meteo data) in its own context.",
});The filename weather.ts makes the MCP server name weather. The agent field points to the sibling project's mount slug.
This differs from a subagent. A peer keeps its own:
- root instructions,
- tools and MCP connections,
- durable sessions,
- playground, and
- public MCP endpoint.
An SDK subagent inherits the parent's execution surface and only its parent can invoke it. See Agent-to-agent for the full comparison.
Follow a delegated request
- A user asks Concierge what to pack for Paris.
instructions.mdclassifies packing advice as weather-related.- The model calls
weather.askwith the city, timeframe, units, and the complete question. - The Agent SDK creates an MCP-channel session inside
weather-agent. - Weather agent calls its own Open-Meteo tools and returns a reply.
- If the turn exceeds the bounded MCP wait,
askreturnsstatus: "running". Concierge callsweather.checkwith the returnedsessionId. - Concierge relays the result and may add one sentence of travel advice.
The weather session appears in the weather agent's playground. It doesn't share Concierge's conversation history.
Map the delegation files
| File | Purpose |
|---|---|
agent/agent.ts | Describes the root agent and selects the local runtime. |
agent/instructions.md | Draws a strict weather-only delegation boundary. |
agent/mcp-connections/weather.ts | Resolves the peer by its weather-agent slug. |
agent/storage.ts | Persists sessions and events with cursorHostedStorage. |
Concierge doesn't author channels, tools, skills, subagents, schedules, hooks, A/B experiments, or evals. The built-in HTTP and MCP surfaces still exist.
Its own MCP endpoint exposes ask and check. It doesn't expose call_tool because Concierge has no server tools. The target weather agent does expose call_tool, so that tool also appears under Concierge's weather connection.
Mount both agents
A peer can only resolve within a multi-agent serve host. Validating Concierge alone checks its files, but serving it alone fails because weather-agent isn't mounted.
From packages/agent-serve, validate both projects:
bash
agent-sdk validate --dir examples/concierge
agent-sdk validate --dir examples/weather-agentDon't serve the repository's whole examples/ directory for this proof. Several advanced examples subscribe to live GitHub events. Create an ignored two-project mount instead. Copy only the authored files needed for this proof, leaving Weather's Slack channels out:
bash
mkdir -p "$PWD/.agent-serve"
PAIR_DIR=$(mktemp -d "$PWD/.agent-serve/concierge-weather.XXXXXX")
mkdir -p "$PAIR_DIR/concierge" "$PAIR_DIR/weather-agent/agent"
cp -R examples/concierge/agent "$PAIR_DIR/concierge/"
cp examples/concierge/package.json "$PAIR_DIR/concierge/"
cp examples/weather-agent/agent/{agent.ts,instructions.md,ab.ts,ab.config.ts} \
"$PAIR_DIR/weather-agent/agent/"
cp -R examples/weather-agent/agent/{tools,skills,mcp-connections,subagents,schedules,hooks,lib} \
"$PAIR_DIR/weather-agent/agent/"
cp -R examples/weather-agent/mcp "$PAIR_DIR/weather-agent/"
cp examples/weather-agent/package.json "$PAIR_DIR/weather-agent/"
agent-sdk dev "$PAIR_DIR"The host resolves the peer after it knows every mount. The local peer URL is http://127.0.0.1:3000/weather-agent/v1/mcp. You still need an agent-runtime credential for both model turns.
Exercise delegation
Send a weather request to the running Concierge:
bash
agent-sdk chat \
--url http://127.0.0.1:3000/concierge \
--message "What should I pack for Paris tomorrow?"Open both playgrounds:
http://127.0.0.1:3000/concierge/playgroundhttp://127.0.0.1:3000/weather-agent/playground
The Concierge transcript shows the MCP call. The weather playground shows a separate session on the mcp channel with live weather tool calls.
Now send a general request:
bash
agent-sdk chat \
--url http://127.0.0.1:3000/concierge \
--message "Give me three ideas for a quiet weekend."The instructions tell Concierge to answer without delegating. This contrast is the proof loop: weather goes to the peer, unrelated work stays local.
Preserve peer context
weather.ask returns a peer sessionId. Passing it back to a later ask continues the same weather conversation. Concierge's instructions require this for follow-ups dependent on an earlier answer.
Use a fresh call when the tasks are independent. Reuse the peer session when the second question needs facts or choices from the first.
Keep delegation bounded
The Agent SDK rejects unknown peer slugs and self-references during startup. It doesn't stop a cycle across several valid peers. If agent A delegates all work to B and B delegates all work to A, they can recurse.
The prompt provides the guardrail here:
- delegate every weather request,
- include complete context, and
- never delegate unrelated work.
Write similarly narrow routing rules for each peer. A tool description helps the model choose the connection, but the always-on instructions own the policy.
Use peers from cloud turns
Local turns reach peers over loopback. A cloud VM can't reach the serve host's loopback address. Set a public URL when a cloud agent needs the peer:
bash
agent-sdk serve --dir "$PAIR_DIR" \
--public-url https://agents.example.com \
--bearer-token "$AGENT_TOKEN"The Agent SDK attaches the bearer token to peer calls. Without --public-url, cloud turns omit peer connections and the server logs a warning.
Compose your own pair
To compose your own agents:
- Give each project a stable directory slug.
- Add
agent/mcp-connections/<name>.tsto the caller. - Set
agentto the target slug. - Describe the exact work the peer owns.
- Mount both projects from their parent directory.
- Add evals for delegated and non-delegated requests.
Keep the peer independently useful. If the specialist only makes sense inside one parent and needs no independent sessions, use a subagent instead.