CedarCopilot wants to merge 0 commits into staging from feat/wire-chat-agent-md
Live on prod, no production signal yet
Strict CloudWatch fallback found 1 prod failure log lines for [run-chat-agent-sdk] query() failed (Claude Code process aborted by user) in the last 24h while checking /routes, /playbooks/chat_agent.md, /imessage/sms, executionprompt, buildchatorgrulecontext.
Strict CloudWatch fallback found 2 prod failure log lines for [UpdateExternalCrmWorkflow] Driver update failed (User is not connected to HubSpot) in the last 24h while checking builduserchatinstructionsblock, chat_agent, [chat-org-rules] failed to load chat_agent.md.
Strict CloudWatch fallback found 1 prod failure log lines for [run-chat-agent-sdk] query() failed (Claude Code process aborted by user) in the last 24h while checking dynamiccontext, buildchatorgrulecontext, fullprompt, chat_agent, <user_chat_instructions>.
Libra has verdicts on 0 of 3 tracked behaviors on prod; 3 are still being checked. Libra has 3 low-confidence degraded verdicts it is still confirming. Libra checks hourly for 3 days after each deploy.
The per-user user/playbooks/CHAT_AGENT.md doc (seeded by seedPlaybookFiles) had no consumers , nothing read it into any chat agent, so user-authored chat instructions were silently dormant.
Adds a single shared helper and ingests it at every chat entrypoint.
buildUserChatInstructionsBlock(orgId, userId) in chat-org-rules.ts (the module already shared by every chat surface). Reads CHAT_AGENT.md via the existing readDocument service and returns a <user_chat_instructions> block, or '' when the doc is missing/empty/whitespace (or orgId is null). Non-fatal (try/catch, log-and-continue) , a chat turn is never blocked. Single source of truth; no duplicated read logic.
| Entrypoint | Ingested via |
|---|---|
In-app chat , Agent-SDK harness (direct-Anthropic query()) | chat-workflow.ts (top of dynamicContext → executionPrompt) |
In-app chat , Mastra chatAgent.stream() fallback | same executionPrompt (shared assembly) |
| Slack bot | shared buildChatOrgRuleContext (first section) |
| iMessage bot | shared buildChatOrgRuleContext |
| SMS bot | shared buildChatOrgRuleContext |
| Understudy-gateway variants of the above | same executionPrompt , covered transitively |
Placed first in each surface's dynamic context so it's the top of what the model reads.
Out of scope (verified): WhatsApp is notify-only (no chat-agent handler); roadmap chat runs a distinct roadmapAgent; the event-execution agent already reads playbooks separately.
Enables per-user chat customization generally, and specifically makes an engagement wiki-review flow (authored into a user's CHAT_AGENT.md) reachable from in-app chat and the headless surfaces.
pnpm --filter @zero/server run types → 0 errors in the two touched files (chat-org-rules.ts, chat-workflow.ts); the 9 build errors are pre-existing and unrelated.
🤖 Generated with Claude Code
The PR adds a shared reader for each user's CHAT_AGENT.md and prepends its contents to in-app and standard Slack, SMS, and iMessage chat prompts.
The Slack approval continuation should ingest CHAT_AGENT.md before merging so accepted actions do not bypass the user's configured chat behavior.
Standard in-app and bot prompts receive the new block, but the independent Slack agent_prompt operation still invokes the chat agent using only its preamble and approval text.
Files Needing Attention: apps/server/src/mastra/workflows/chat/chat-org-rules.ts and apps/server/src/mastra/operations/operation-registry.ts
| Filename | Overview |
|---|---|
| apps/server/src/mastra/workflows/chat/chat-org-rules.ts | Adds the scoped CHAT_AGENT.md reader and standard headless injection, but this shared composition is not used by the Slack approval agent invocation. |
| apps/server/src/mastra/workflows/chat/chat-workflow.ts | Prepends the instruction block to the executionPrompt shared by the in-app Agent SDK and Mastra paths. |
Libra has not measured any production surfaces for this change yet.