Skip to content

Commit 6137fd0

Browse files
committed
fix(webapp): expire dashboard agent turn runs that are never dequeued
1 parent 32be0d4 commit 6137fd0

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

apps/webapp/app/services/dashboardAgent.server.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,18 @@ export function isDashboardAgentConfigured(): boolean {
8888
return Boolean(env.DASHBOARD_AGENT_SECRET_KEY);
8989
}
9090

91+
// With no agent worker available a turn's run would sit queued indefinitely and
92+
// could be dequeued much later with a stale token. Expire it instead — the turn
93+
// is long dead by then on the client.
94+
const DASHBOARD_AGENT_RUN_TTL = "2m";
95+
9196
// Pins every agent session (and its continuation runs) to a deployed version
9297
// when DASHBOARD_AGENT_VERSION is set; unset runs on the env's current version.
93-
export function dashboardAgentTriggerConfig(): { lockToVersion: string } | undefined {
94-
return env.DASHBOARD_AGENT_VERSION ? { lockToVersion: env.DASHBOARD_AGENT_VERSION } : undefined;
98+
export function dashboardAgentTriggerConfig(): { ttl: string; lockToVersion?: string } {
99+
return {
100+
ttl: DASHBOARD_AGENT_RUN_TTL,
101+
...(env.DASHBOARD_AGENT_VERSION ? { lockToVersion: env.DASHBOARD_AGENT_VERSION } : {}),
102+
};
95103
}
96104

97105
export async function startDashboardAgentSession(params: {

apps/webapp/app/services/realtime/sessionRunManager.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ async function triggerSessionRun(params: {
310310
...(config.maxDuration !== undefined ? { maxDuration: config.maxDuration } : {}),
311311
...(config.lockToVersion ? { lockToVersion: config.lockToVersion } : {}),
312312
...(config.region ? { region: config.region } : {}),
313+
...(config.ttl !== undefined ? { ttl: config.ttl } : {}),
313314
},
314315
};
315316

0 commit comments

Comments
 (0)