CedarCopilot wants to merge 2 commits into staging from worktree-send-it-chat-harness-tool-deferral
Libra ran this behavior against the change and confirmed the check detects when it breaks.
Changed code: delegate-tool-scoping.ts.
Libra ran this behavior against the change and confirmed the check detects when it breaks.
Libra ran this behavior against the change and confirmed the check detects when it breaks.
Changed code: delegate-tool-scoping.ts.
Libra ran this behavior against the change and confirmed the check detects when it breaks.
Changed code: delegate-tool-scoping.ts.
Live on prod, watching, 2 days left
Libra has verdicts on 0 of 3 tracked behaviors on prod; 3 are still being checked. Libra checks hourly for 3 days after each deploy.
ToolSearch was missing from options.tools (the SDK restricts built-ins to the names listed, so tool-search deferral was silently off and all MCP schemas loaded every turn), and alwaysLoad: true on every user MCP server pinned their schemas into context even with deferral on.ToolSearch in the allowlist (new pure, tested buildAllowedTools) and drop alwaysLoad from user MCP server configs. Tools are now discovered on demand.pending at the start of a turn is not in the deferred list, the harness system prompt now carries one extra line naming the user's configured servers and telling the model to use ToolSearch for them (sorted and deduplicated so the prompt is byte-stable for caching, names over 64 chars dropped, capped at 20, no line at all when there are no servers).check-brand-assets, oxlint --deny-warnings, pnpm deps:check (no violations), pnpm run types (apps/server) all clean. Not run: full pnpm run autofix:local (it ends in an unscoped vitest run src/ and the whole mail Jest suite, which this repo's hygiene rules forbid).src/mastra/workflows/chat (14 files, 169 tests) passes after merging staging. New/changed tests: context-telemetry.test.ts (summarizers and the observe closure incl. never-throws), delegate-tool-scoping.test.ts (buildAllowedTools includes ToolSearch; the connected-servers line: sorted, deduplicated, byte-identical across input orders, cap at 20, long/reserved names dropped, single line, unchanged prompt for no servers), user-mcp-servers.test.ts (alwaysLoad absent on every server config)./context baseline for a Notion-connected user: 193.9k (97%) -> 23.5k (12%); a no-external-MCP control 131k -> 25k.Autocompact is thrashing error (3 compactions, 190s); with this change it completes, 0 compactions, first request ~42k tokens (re-verified on the final commit).ToolSearch then the Notion tool; a server reported pending at init was still discovered in the same turn and was listed as configured from the prompt line.Log lines from run-chat-agent-sdk.ts (emitted once per Claude-mode chat turn):
cedar-prod-logs (also cedar-staging-logs) , query:
['cedar-prod-logs'] | where _time > ago(1h) and message == "[run-chat-agent-sdk] first request context"
| summarize p50=percentile(todouble(context_tokens), 50), p95=percentile(todouble(context_tokens), 95), max=max(todouble(context_tokens)) by bin(_time, 10m)
Other lines: [run-chat-agent-sdk] tool baseline (tool_search_available, available_tool_count, available_mcp_tool_count, mcp_servers name+status; counts include deferred tools), [run-chat-agent-sdk] context compacted (trigger, pre_tokens), warns [run-chat-agent-sdk] tool search unavailable and [run-chat-agent-sdk] user MCP server not ready at init (servers name+status), [run-chat-agent-sdk] context telemetry failed.Libra has not measured any production surfaces for this change yet.