From 3b16ac38040dae6a503e42b488956cb48175136a Mon Sep 17 00:00:00 2001 From: tmartin2113 Date: Tue, 7 Jul 2026 18:48:08 -0500 Subject: [PATCH] fix(server): use run.id for activity_log in heartbeat invoke/resume (#3424) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - The heartbeat invoke and resume endpoints log activity with `actor.runId` (the caller's auto-generated run ID from JWT), which hasn't been registered in `heartbeat_runs` yet - This causes a FK constraint violation: `activity_log.run_id → heartbeat_runs.id` - Fix: use `run.id` (the newly created heartbeat_run) instead, which is guaranteed to exist in the table ## Test plan - [ ] Trigger a heartbeat invoke via the API — verify no FK constraint error in logs - [ ] Trigger a heartbeat resume — verify activity_log row is created successfully - [ ] Verify existing activity_log queries still return correct results 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 (1M context) --- server/src/routes/agents.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/routes/agents.ts b/server/src/routes/agents.ts index 659491cac5..685fe3900c 100644 --- a/server/src/routes/agents.ts +++ b/server/src/routes/agents.ts @@ -3329,7 +3329,7 @@ export function agentRoutes( actorType: actor.actorType, actorId: actor.actorId, agentId: actor.agentId, - runId: actor.runId, + runId: run.id, action: "heartbeat.invoked", entityType: "heartbeat_run", entityId: run.id, @@ -3420,7 +3420,7 @@ export function agentRoutes( actorType: actor.actorType, actorId: actor.actorId, agentId: actor.agentId, - runId: actor.runId, + runId: run.id, action: "heartbeat.invoked", entityType: "heartbeat_run", entityId: run.id,