fix: harden heartbeat and adapter runtime workflows

This commit is contained in:
Dotta 2026-04-10 22:26:21 -05:00
parent 548721248e
commit c566a9236c
48 changed files with 14922 additions and 600 deletions

View file

@ -2441,15 +2441,14 @@ export function agentRoutes(db: Db) {
}
assertCompanyAccess(req, issue.companyId);
let run = issue.executionRunId ? await heartbeat.getRun(issue.executionRunId) : null;
let run = issue.executionRunId ? await heartbeat.getRunIssueSummary(issue.executionRunId) : null;
if (run && run.status !== "queued" && run.status !== "running") {
run = null;
}
if (!run && issue.assigneeAgentId && issue.status === "in_progress") {
const candidateRun = await heartbeat.getActiveRunForAgent(issue.assigneeAgentId);
const candidateContext = asRecord(candidateRun?.contextSnapshot);
const candidateIssueId = asNonEmptyString(candidateContext?.issueId);
const candidateRun = await heartbeat.getActiveRunIssueSummaryForAgent(issue.assigneeAgentId);
const candidateIssueId = asNonEmptyString(candidateRun?.issueId);
if (candidateRun && candidateIssueId === issue.id) {
run = candidateRun;
}
@ -2466,7 +2465,7 @@ export function agentRoutes(db: Db) {
}
res.json({
...redactCurrentUserValue(run, await getCurrentUserRedactionOptions()),
...run,
agentId: agent.id,
agentName: agent.name,
adapterType: agent.adapterType,