Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

feat(oss-rollout): open-weight workload segmentation across Cedar's automation tasks

merged#2829CedarCopilot

CedarCopilot wants to merge 3 commits into staging from feat/oss-workload-segmentation

Live on prod, 0 of 1 surfaces working, 1 day leftTimeline and evidence
  1. Opened
    Sep 19, 2026, 4:15 PM
  2. Sep 19, 2026, 5:50 PM
  3. Merged
    Sep 19, 2026, 8:14 PM
  4. Live on prod
    Sep 19, 2026, 8:14 PM
  5. Observed 2 hours, 1 surface, 0 requests
    Sep 19, 2026, 8:14 PM
  6. Watching

    Live on prod, 0 of 1 surfaces working, 1 day left

    Sep 19, 2026, 8:14 PM
  7. Pipelines steady after this deploy
    Sep 19, 2026, 8:14 PM

Behaviors Libra is checking

Each agent execution persists every underlying LLM response correlation ID, workload, model, and creation time in the atomic `agent_executions.llm_calls` array.Not checked
prod
The analyzer workflow has a registered Sol open-weight agent variant using the dedicated analyzer OSS workload and the existing analyzer tool set.Not checked
prod
AOP selection uses the Sol open-weight model through Understudy when the AOP-selection OSS task flag is enabled and otherwise preserves the existing GPT-4o route.Not checked
prod
User-authored custom automation subagents can route to the Sol open-weight agent through the separately gated custom-subagents OSS workload.Not checked
prod
Named default automation patterns for strategist, pipeline review, meeting prep, daily agenda, coaching, and inbound email notification can each route to their own Sol open-weight Understudy workload under the system-subagents rollout.Not checked
prod
Chat requests from the operation registry, Slack, SMS, and iMessage use the Sol open-weight Chat Agent through Understudy when the chat OSS flag is enabled, with family-surface requests selecting the corresponding OSS family agent.Not checked
prod

Libra found 1 production surface on prod but could not judge any of them yet. 1 surface had no requests at all. Libra checks hourly for 3 days after each deploy.

Summary

Full open-weight ("oss") workload segmentation across Cedar's automation tasks , per the Aamir/Isabelle Slack thread and follow-up design work. services/llm/oss-tasks.ts is the single registry (23 tasks, 14 PostHog flag groups); every task listed there now has real routing, gated by isOssFlagEnabled(OSS_TASKS[task].flagGroup, userId) resolved alongside each call site's existing feature flags.

Foundation (unchanged from the original PR):

  • services/llm/oss-tasks.ts , the one place a task's default/oss Understudy workload pair and PostHog flag group are declared.
  • isOssFlagEnabled (posthog.ts) , the one place a flag group becomes a real PostHog key (cedar-oss-<group>).
  • agent_executions.llm_calls (jsonb) , one entry per underlying LLM call (correlation id, workload, model), appended atomically via services/agent-action-queue/llm-calls.ts.

Oneoffs , event-summarization.ts, company-domain-assignment.ts (domain identification), aop-selection.ts, stage-classification.ts (services/crm/ , no per-request userId available on this backfill path, so the flag check uses a fixed 'system' identity), on-event-email-orchestrator (M1) + a new on-event-meeting-orchestrator oss variant, drafter (M2).

Orchestrator / chat / analyzer , orchestrator-agent.ts (+ createOrchestratorAgentOss, wired in execute-orchestrator.ts), chat-agent.ts (+ chatAgentOss/chatAgentOssFamilies, wired across its 5 call sites: sms/slack/imessage bot chat, chat-workflow.ts, operation-registry.ts), analyzer-agent.ts (+ createAnalyzerAgentOss, wired in execute-analyzer.ts).

Tier 3 renames (workload identity, not just a label) , conversation-field-updatercrm-updater, conversation-field-updater-haikucrm-updater-haiku, strategist-updaterstrategist, next-steps-tasksnext-steps. Code and the real Understudy workloads (renamed via CLI) both updated; new -oss workloads created for all four.

Tier 4 , automation-agent.ts gets per-pattern oss singletons (via a createAutomationAgentOss factory) for the 6 named defaults that were sharing the generic automation workload (meeting-prep, daily-agenda, pipeline-review, coach-meeting, coach-weekly, inbound-email-notifier) plus strategist's scheduled/cron path, and a custom-subagent-oss variant for the long tail of arbitrary user-authored subagents. Wired into automations.ts's runAutomationInProcess, which checks the oss flag before falling back to the older flat MODEL_EXPERIMENT_PATTERNS/automationAgentSol experiment (kept, not deleted, as the pre-oss fallback). automationAgent/automationAgentUnderstudy deliberately keep their existing automation workload name rather than renaming to custom-subagent , it's the platform's highest-volume workload, and that rename needs its own sign-off (see Open questions).

Every new static Agent singleton is registered on the root Mastra instance in mastra/index.ts.

Deliberately not in this PR

  • taxonomy-field-values/taxonomy-judgments , these already have -glm/-kimi per-model Understudy workloads from an earlier, separate experiment. -oss workloads/flags exist (created, inactive/0%) but nothing is wired to them, to avoid conflicting with that existing convention.
  • Renaming automationcustom-subagent , see Open questions below.
  • org_id/user_id/segment_id as literal Understudy request headers on the static Agent singletons , their model is fixed at module-load time with no per-request context threading today. Metadata is captured in llm_calls instead, which is request-scoped.

Real bugs found and fixed while wiring this in

  • Meeting-path telemetry mislabeling (M1): the orchestrator's logPromptCacheUsage call hardcoded workload: 'on-event-email-orchestrator' regardless of which branch ran, silently mislabeling every meeting-triggered call. Pre-existing, not introduced by this PR. Fixed by deriving the wor
Show production surfaces and changed-file mapping

Production surfaces

SurfaceRequestsErrorsp95UsersVerdict
cron-task-queue.processAopAutomations7 → 00 → 0 (0%)1675 ms → not measured0No traffic
No requests recorded since this deploy.

Changed files → surfaces

  • apps/server/src/services/aop/automations.tscron-task-queue.processAopAutomations
  • apps/server/src/db/aop-schema.tsno production surface mapped
  • apps/server/src/db/migrations/0056_agent_executions_llm_calls.sqlno production surface mapped
  • apps/server/src/db/migrations/meta/_journal.jsonno production surface mapped
  • apps/server/src/mastra/agents/analyzer-agent.tsno production surface mapped
  • apps/server/src/mastra/agents/automation-agent.tsno production surface mapped
  • apps/server/src/mastra/agents/chat-agent.tsno production surface mapped
  • apps/server/src/mastra/agents/on-event-execution-agent.tsno production surface mapped
  • apps/server/src/mastra/agents/on-event-orchestrator-agent.tsno production surface mapped
  • apps/server/src/mastra/agents/sub-agents/orchestrator-agent.tsno production surface mapped
  • apps/server/src/mastra/index.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/slack-bot-chat.tsno production surface mapped
  • apps/server/src/mastra/routeHandlers/sms/sms-bot-chat.tsno production surface mapped
  • apps/server/src/mastra/tools/event-execution/__tests__/drafter-executor-prompt.test.tsno production surface mapped
  • apps/server/src/mastra/tools/event-execution/orchestrator-dispatch-tools.tsno production surface mapped
  • apps/server/src/mastra/tools/task/updateNextStepsAndTasksTool.tsno production surface mapped
  • apps/server/src/mastra/utils/__tests__/prompt-cache-fetch.test.tsno production surface mapped
  • apps/server/src/mastra/utils/aop-selection.tsno production surface mapped
  • apps/server/src/mastra/utils/company-domain-assignment.tsno production surface mapped
  • apps/server/src/mastra/utils/conversation-field-updates.tsno production surface mapped
  • apps/server/src/mastra/utils/event-summarization.tsno production surface mapped
  • apps/server/src/mastra/utils/execution/execute-analyzer.tsno production surface mapped
  • apps/server/src/mastra/utils/execution/execute-orchestrator.tsno production surface mapped
  • apps/server/src/mastra/utils/prompt-cache-fetch.tsno production surface mapped
  • apps/server/src/mastra/utils/strategist-updates.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/chat-workflow.tsno production surface mapped
  • apps/server/src/mastra/workflows/event-execution/on-event-agent-execution-workflow.tsno production surface mapped
  • apps/server/src/services/agent-action-queue/llm-calls.tsno production surface mapped
  • apps/server/src/services/aop/__tests__/automations-service.test.tsno production surface mapped
  • apps/server/src/services/crm/stage-classification.tsno production surface mapped
  • apps/server/src/services/llm/__tests__/oss-tasks.test.tsno production surface mapped
  • apps/server/src/services/llm/models.tsno production surface mapped
  • apps/server/src/services/llm/oss-tasks.tsno production surface mapped
  • apps/server/src/services/posthog/__tests__/oss-flags.test.tsno production surface mapped
  • apps/server/src/services/posthog/posthog.tsno production surface mapped