Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

feat(chat): flag-gated Master-agent family tool surface

merged#2555CedarCopilot

CedarCopilot wants to merge 14 commits into staging from tool-surface/master-agent-families

Live on prod, no production signal yetTimeline and evidence
  1. Opened
    Aug 23, 2026, 2:43 PM
  2. Aug 25, 2026, 6:37 PM
  3. Merged
    Aug 25, 2026, 7:23 PM
  4. Live on prod
    Aug 25, 2026, 7:23 PM
  5. Observed 3 days
    Aug 25, 2026, 7:23 PM
  6. Pipelines steady after this deploy
    Aug 25, 2026, 7:23 PM
  7. Unobserved

    Live on prod, no production signal yet

    Aug 28, 2026, 7:10 PM

Behaviors Libra is checking

Dashboard UI behavior from ui-config/uiConfigTool.ts keeps working in prod.Degradedlow confidence

Strict CloudWatch fallback found 2 prod failure log lines for [run-chat-agent-sdk] query() failed (Claude Code process aborted by user) in the last 24h while checking /uiconfigtool.ts, uiconfigtool, chatatoms, reasoningeffortpicker, agentconnectionslice.

prod, checked Aug 28, 2026, 7:10 PM
Chat workflow behavior from agents/chat-agent.ts, imessage/imessage-bot-chat.ts, slack/slack-bot-chat.ts keeps working in prod.Inconclusivelow confidence

Strict CloudWatch fallback found 10 prod failure log lines for [backfillSlackChannelHistory] Backfill failed (Superglue workflow failed: fetch failed), but this domain-wide failure family is not tied to this intent.

prod, checked Aug 28, 2026, 6:08 PM
CRM integration behavior from account-config/contextual-instructions.ts keeps working in prod.Inconclusivelow confidence

Strict CloudWatch fallback found 1 recent prod failure log lines for [UpdateExternalCrmWorkflow] Driver update failed (No valid values in \), but the same failure had 1 log lines in the comparable pre-deploy baseline. Libra is not blaming this PR intent without a post-deploy.

prod, checked Aug 28, 2026, 6:08 PM
Email workflow behavior from atoms/chatAtoms.ts, chatInput/ReasoningEffortPicker.tsx, agentConnection/agentConnectionSlice.ts keeps working in prod.Inconclusivelow confidence

Strict CloudWatch fallback saw 10,160 success-shaped log lines matching email, emails, gmail, mail, inbox, but no tied operation was present, so Libra is not calling this working.

prod, checked Aug 26, 2026, 12:03 AM

Libra has verdicts on 0 of 4 tracked behaviors on prod; 4 are still being checked. Libra has 1 low-confidence degraded verdict it is still confirming. Libra checks hourly for 3 days after each deploy.

What & why

Give the Mastra chat agents (the flag-OFF "Master" path) the same consolidated Tool Families the external MCP server and the SDK harness already use , instead of the flat granular skill tools , behind an OFF-by-default feature flag (cedar-master-agent-families). Design doc: docs/design/master-agent-tool-families-migration.md (in this PR).

The families are thin facades over the exact same granular tools the agent already runs, so this is a re-addressing at the registration/prompt layer, not a re-implementation. getAllSkillTools() and every granular tool are untouched, so background automation and orchestrator/analyzer subagents keep running on the original surface until a full migration.

Safety model

  • Flag defaults OFF → merging changes nothing in prod. The OFF path is byte-identical (verified by tracing every branch).
  • The flag gates the cutover for all 5 chat entrypoints: in-app chat + Slack / iMessage / SMS bots + the Slack-approval path. Slack is the one live path today.
  • Background/automation agents are deliberately not touched , they source tools independently (own getAllSkillTools() calls / direct imports / getPipelineAgentTools()), and none reuse the chatAgent instance.

What's in it

  • New families (facades via delegateToTool):
    • chat-context (manage / resolve) , in-app only
    • delegate (subagent / code) , in-app only
    • ui-config.configure-overview , generalizes the former configure-strategist onto ui-config (it's a view/layout catalog, not an agent tool)
  • IN_APP_ORCHESTRATION_FAMILIES + buildMasterFamilyToolset(); load-skill stays a constructor tool; list-aops dropped (→ config-read read-playbook mode:"list", verified field-parity).
  • mastra-families prompt surface + selectChatAgent(); family agent variants registered in the Mastra instance for telemetry + memory parity.
  • Frontend untouched: reuses the harness's toLegacyToolName shim at the two emit sites, so family tool-call cards render as the legacy flat names.
  • scope-map: ui-config becomes an action-override family (configure-overviewplaybook:write).

Verification

  • pnpm --filter @zero/server run types0 errors
  • pnpm deps:checkno violations (1518 modules)
  • vitest: new master-surface.test.ts + updated scope-map.test.ts104 passed; external MCP schema tests (server + tool-inputschema-size + tool-description-length) → 65 passed
  • Ran /thermo-review on the diff , no blocking findings; one gap (family agents missing Mastra-instance registration) found and fixed in-branch.

⚠️ Before enabling the flag

The mastra-families prompt references granular tool names that are family actions on this surface (same accepted pattern the shipped harness uses; the model bridges via tool descriptions). Keep the flag OFF for real traffic until playbook-instruction-eval confirms fire-rate parity (drafting, opp-creation, subagent spawn, field updates) and a Slack smoke test passes.

Open question for review

configure-overview rides the shared ui-config family, so it's also reachable on the external MCP surface, adding a nested discriminatedUnion (ops) to that schema. Conversion + size tests pass, but the claude.ai connector's runtime handling of the nested anyOf isn't verified here. If we'd rather not expand the external surface, configure-overview can move to the in-app-only set , flagged in the design doc.

🤖 Generated with Claude Code

Greptile Summary

This PR flag-gates a consolidated family-tool surface for Mastra chat agents and aligns chat entrypoints, prompts, telemetry registration, and legacy tool-card naming with that surface. The load-skill translation remains incomplete for several cedar-configuration capabilities.

  • Adds family variants of the Master chat agents and selects them across in-app
Show production surfaces and changed-file mapping

Production surfaces

Libra has not measured any production surfaces for this change yet.

Changed files → surfaces

  • apps/mail/atoms/chatAtoms.tsno production surface mapped
  • apps/mail/modules/cedar-os/src/cedar-os-components/chatInput/ReasoningEffortPicker.tsxno production surface mapped
  • apps/mail/modules/cedar-os/src/store/agentConnection/agentConnectionSlice.tsno production surface mapped
  • apps/server/src/lib/logging/perf-timer.tsno production surface mapped
  • apps/server/src/mastra/agents/chat-agent.tsno production surface mapped
  • apps/server/src/mastra/context/values.tsno production surface mapped
  • apps/server/src/mastra/index.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/__tests__/scope-map.test.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/scope-map.tsno production surface mapped
  • apps/server/src/mastra/operations/operation-registry.tsno production surface mapped
  • apps/server/src/mastra/routeHandlers/imessage/imessage-bot-chat.tsno production surface mapped
  • apps/server/src/mastra/routeHandlers/slack/__tests__/slack-turn-persistence.test.tsno production surface mapped
  • apps/server/src/mastra/routeHandlers/slack/slack-bot-chat.tsno production surface mapped
  • apps/server/src/mastra/routeHandlers/sms/sms-bot-chat.tsno production surface mapped
  • apps/server/src/mastra/skills/account-config/contextual-instructions.tsno production surface mapped
  • apps/server/src/mastra/tools/__tests__/family-tool-names.test.tsno production surface mapped
  • apps/server/src/mastra/tools/__tests__/master-surface.test.tsno production surface mapped
  • apps/server/src/mastra/tools/chat/chatContextTool.tsno production surface mapped
  • apps/server/src/mastra/tools/chat/resolveAndAttachTool.tsno production surface mapped
  • apps/server/src/mastra/tools/family-tool-names.tsno production surface mapped
  • apps/server/src/mastra/tools/integrations/externalMcpTool.tsno production surface mapped
  • apps/server/src/mastra/tools/integrations/runCodeExecutorTool.tsno production surface mapped
  • apps/server/src/mastra/tools/master-surface.tsno production surface mapped
  • apps/server/src/mastra/tools/research/researchTool.tsno production surface mapped
  • apps/server/src/mastra/tools/skills/delegateTool.tsno production surface mapped
  • apps/server/src/mastra/tools/skills/loadSkillTool.tsno production surface mapped
  • apps/server/src/mastra/tools/skills/spawnSubagentTool.tsno production surface mapped
  • apps/server/src/mastra/tools/ui-config/uiConfigTool.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/__tests__/surface-context-parity.test.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/chat-org-rules.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/chat-workflow.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/harness/__tests__/routing.test.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/harness/legacy-tool-name-map.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/harness/request-context.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/harness/routing.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/harness/subagents.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/harness/types.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/harness/user-mcp-servers.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/headless-channel-rules.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/preflight-task.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/run-chat-agent-sdk.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/shared-chat-context.tsno production surface mapped
  • apps/server/src/services/playbook/subagents.tsno production surface mapped
  • apps/server/src/services/posthog/posthog.tsno production surface mapped
  • docs/design/cedar-fast-chat-latency-investigation.mdno production surface mapped
  • docs/design/master-agent-tool-families-migration.mdno production surface mapped
  • docs/design/retiring-the-granular-tool-surface.mdno production surface mapped
  • docs/design/unified-chat-surface-workflow.mdno production surface mapped