CedarCopilot wants to merge 2 commits into staging from perf/db-io-fixes
Libra could not exercise the changed behavior yet: it generated a scenario for this change but has not finished running it, and will report the result once the run completes.
Live on prod, 0 of 11 surfaces working, 2 days left
Libra found 11 production surfaces on prod but could not judge any of them yet. 2 surfaces had under 20 requests, so Libra has not judged them; 9 surfaces had no requests at all. Libra checks hourly for 3 days after each deploy.
Follow-up to the Supabase Disk IO budget investigation. Four independent commits.
Opening one agent batches ~10 agent procedures into one HTTP request. Every one funnelled through resolveAgentForCaller, which rebuilt the caller's entire agent set (AOPs ā every AOP's subagents ā their documents) just to .find() one entry , ~20 db.select spans in a single agent.getConnections trace.
resolveAgents is now memoized per request (agent-read.ts). Keyed on exactly its inputs {userId, orgId}, so no cross-user answers. Staleness is bounded three ways:
agentProcedure middleware in agent.ts)serverTrpc() callers that interleave agent reads with non-router writes inside one long requestcrm.getConversations: bound eventsWith no eventsLimit the events subquery emits no LIMIT and hydrates every event (7,761 / ~9,200 pages for the busiest deal). Its one consumer (use-calendar-canvas-data) never reads events, so passing CONVERSATION_OVERVIEW_EVENTS_LIMIT changes nothing rendered.
Deliberately not applied to getConversation (single): most of its 45 callers feed events to the agent, so capping would change behaviour.
agent_tool_calls retentionThe one-off prune removed 2.07M rows; the table re-accrues ~1.1M/month. Adds pruneAgentToolCalls to the daily 3am UTC slow lane, bounded to 200k rows per step per run. Safety rules stay in the service (draft-email never touched, <7-day windows refused, refuses without a valid created_at index , which exists in prod).
unindexed_fk_hot_tables.sql records three FK indexes + a duplicate-index drop already applied to prod. Two of them were why account deletion took 136 s per 500-row batch.
cedar-prod, db.select span count per trpc.agent.* trace should fall from ~20 to single digits.[pruneAgentToolCalls] retention pass complete with deleted_rows, blanked_rows, *_backlog_remains.trpc.crm.getConversations p95.agent-resolution-memo.test.ts (8): scoping, cross-user isolation, invalidation, TTL, failed-resolution not cachedprune-agent-tool-calls.test.ts (3): always applies, always bounded, releases connection on errortypes, types:test, deps:check cleanš¤ Generated with Claude Code
The behavioral changes appear sound, but the explicit repository prohibition on unchecked TypeScript casts must be satisfied before merging.
### Issue 1
apps/server/src/cron/__tests__/prune-agent-tool-calls.test.ts:55
This test casts the mocked argument to `{ maxBatches?: number }` instead of narrowing or deriving its type. That violates the repository directive prohibiting TypeScript assertions used to silence shape errors, leaves the mock contract unchecke
| Surface | Requests | Errors | p95 | Users | Verdict |
|---|---|---|---|---|---|
| orchestrator_agent_step | 19 ā 10 | 0 ā 0 (0%) | 222157 ms ā 7741 ms | 9 | Insufficient traffic 10 requests, under the 20 Libra needs |
| model_chunk Automation Agent (Understudy) | 3 ā 6 | 0 ā 0 (0%) | 1 ms ā 1 ms | 0 | Insufficient traffic 6 requests, under the 20 Libra needs |
| /api/trpc/agentExecutions.findRecentTrees | 0 ā 0 | 0 ā 0 (0%) | not measured | 0 | No traffic No requests recorded since this deploy. |
| /api/trpc/agentExecutions.getAgentExecutions | 0 ā 0 | 0 ā 0 (0%) | not measured | 0 | No traffic No requests recorded since this deploy. |
| POST /api/trpc/agentExecutions.getAgentExecutions | 0 ā 0 | 0 ā 0 (0%) | not measured | 0 | No traffic No requests recorded since this deploy. |
| model_chunk On-Event Execution Agent (Understudy) | 2 ā 0 | 0 ā 0 (0%) | 1 ms ā not measured | 0 | No traffic No requests recorded since this deploy. |
| model_chunk Automation Agent (Sol experiment) | 0 ā 0 | 0 ā 0 (0%) | not measured | 0 | No traffic No requests recorded since this deploy. |
| /api/trpc/agent.list | 0 ā 0 | 0 ā 0 (0%) | not measured | 0 | No traffic No requests recorded since this deploy. |
| /api/trpc/aopAgents.listForConversation | 0 ā 0 | 0 ā 0 (0%) | not measured | 0 | No traffic No requests recorded since this deploy. |
| /api/trpc/agent.getOutputs | 0 ā 0 | 0 ā 0 (0%) | not measured | 0 | No traffic No requests recorded since this deploy. |
| /api/trpc/agent.get | 0 ā 0 | 0 ā 0 (0%) | not measured | 0 | No traffic No requests recorded since this deploy. |