feat(claude): warm up sessions for agents that expose MCPs
`ClaudeCodeOptions.warmup_turn` defaults to `None`, which decides per agent: on when the agent exposes any MCP, off otherwise. An agent whose tools are the point shouldn't answer its first message without them, and an agent with no MCPs shouldn't pay for a warm-up it gains nothing from. The underlying reason lives in claude-code-api: the CLI connects MCP servers when a turn starts and doesn't await them, so turn one runs with built-in tools only.
This commit is contained in:
@@ -197,6 +197,12 @@ def _build_backend_options(
|
||||
mcp_servers=_build_mcp_servers(agent, mcp_internal_urls),
|
||||
transport=opt.transport,
|
||||
include_partial_messages=opt.include_partial_messages,
|
||||
# ``None`` means "decide from the agent": an agent that exposes
|
||||
# MCPs needs them on its first reply, one that doesn't shouldn't
|
||||
# pay for a warm-up it gains nothing from.
|
||||
warmup_turn=(
|
||||
bool(agent.expose_mcps) if opt.warmup_turn is None else opt.warmup_turn
|
||||
),
|
||||
disallowed_tools=opt.disallowed_tools,
|
||||
permission_mode=opt.permission_mode,
|
||||
dangerously_skip_permissions=opt.dangerously_skip_permissions,
|
||||
|
||||
Reference in New Issue
Block a user