feat: customer-prompt-task passes its Trigger run id to POST /api/chat/runs
Implements row 3 of recoupable/chat#1958.
What changed
generateChatgains optionaltriggerRunId→ sent astrigger_run_idin thePOST /api/chat/runsbody (omitted when absent)customerPromptTaskpasses its own run id from the Trigger context
Two lines of intent: the run that kicks off a chat generation identifies itself, so any email the agent sends can be linked back (email_send_log.trigger_run_id, database#57) and the run named by that email's subject in the tasks UI.
Inert until the api write path (chat#1958 row 4) reads the field — the api ignores unknown body fields today, so this is safe to merge first.
Tests
TDD red → green: generateChat includes/omits trigger_run_id (2 new); customerPromptTask passes ctx.run.id and tolerates missing ctx (2 new). Full suite + tsc green.
Contract
docs#268 (ChatGenerateRequest.trigger_run_id).
🤖 Generated with Claude Code
Summary by cubic
Threads the scheduled task’s Trigger run id through chat generation. Previously POST /api/chat/runs had no run provenance; now generateChat includes trigger_run_id when provided, and customerPromptTask passes its own id.
Review and rollout
- Adds an optional
triggerRunIdparam togenerateChat, serialized astrigger_run_idin the request body and omitted when undefined. customerPromptTaskforwardsctx.run.idand tolerates missing context.- Backend currently ignores unknown body fields; safe to merge ahead of the write path. No migration required.
- Tests cover include/omit behavior and task forwarding.
Summary by CodeRabbit
-
New Features
- Chat generation now supports including an optional execution run ID with API requests.
- Customer prompt tasks automatically forward their current execution run ID when available.
-
Tests
- Added coverage for including and omitting run IDs in chat requests.
- Added coverage for task behavior with and without execution context.