You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 455c2bd
Browse filesBrowse the repository at this point in the historyBrowse files
fix(mothership): start no tool call with less than a minute of its deadline left (#9092)
* fix(mothership): start no tool call with less than a minute of its deadline left
* fix(mothership): refuse a late claim at the database and settle an unclaimed call as not run
'Tool execution lost its owner before a result was recorded. Its outcome is unknown; inspect current state before retrying a mutation.'
21
21
22
22
/**
23
-
* A takeover re-runs an interrupted call only with at least this much of its deadline left;
24
-
* otherwise the call fails with {@link DEADLINE_SIM_TOOL_MESSAGE} instead of starting work
25
-
* that could not finish in time.
23
+
* A call starts, the first time or again after a takeover, only with at least this much of its
24
+
* deadline left; otherwise it fails as not run instead of starting work that would likely be cut
25
+
* off with its outcome unknown. About 99% of non-workflow tool calls finish within a minute.
26
26
*/
27
-
exportconstSIM_TOOL_RERUN_MIN_REMAINING_MS=60_000
27
+
exportconstSIM_TOOL_MIN_START_BUDGET_MS=60_000
28
28
29
29
exportconstDEADLINE_SIM_TOOL_MESSAGE=
30
30
'Tool execution was interrupted because the Sim server running it stopped, and too little of its time remained to run it again. Its outcome is unknown; inspect current state before retrying a mutation.'
/** A call whose deadline leaves less than a re-run needs; a call without one never matches. */
895
-
consttooLateToRerun=sql`(${copilotAsyncToolCalls.executionDeadlineAt} IS NOT NULL AND ${copilotAsyncToolCalls.executionDeadlineAt} < clock_timestamp() + ${SIM_TOOL_RERUN_MIN_REMAINING_MS} * interval '1 millisecond')`
894
+
/**
895
+
* A call whose deadline leaves less than the minimum start budget, so nothing may start it: no
896
+
* re-run and no claim. A call without a deadline never matches.
897
+
*/
898
+
consttooLateToStart=sql`(${copilotAsyncToolCalls.executionDeadlineAt} IS NOT NULL AND ${copilotAsyncToolCalls.executionDeadlineAt} < clock_timestamp() + ${SIM_TOOL_MIN_START_BUDGET_MS} * interval '1 millisecond')`
896
899
897
900
/**
898
901
* A Sim execution whose owner died before recording a result: its lease lapsed, which a live
// The executor takes only a call Sim offered it, inside its pickup window; once the
1034
1038
// window closed the call belongs to its not-started settlement.
1035
1039
executor
@@ -1135,7 +1139,7 @@ export async function getChatViewDesktopLeaseRemainingMs(
1135
1139
* Why a lapsed execution ended without a result: once, after every re-run it was allowed, or
1136
1140
* with too little of its deadline left to run again.
1137
1141
*/
1138
-
constinterruptionMessage=sql<string>`CASE WHEN ${copilotAsyncToolCalls.executionAttempts} >= ${SIM_TOOL_EXECUTION_MAX_ATTEMPTS} THEN ${EXHAUSTED_SIM_TOOL_MESSAGE}::text WHEN ${tooLateToRerun} THEN ${DEADLINE_SIM_TOOL_MESSAGE}::text ELSE ${INTERRUPTED_SIM_TOOL_MESSAGE}::text END`
1142
+
constinterruptionMessage=sql<string>`CASE WHEN ${copilotAsyncToolCalls.executionAttempts} >= ${SIM_TOOL_EXECUTION_MAX_ATTEMPTS} THEN ${EXHAUSTED_SIM_TOOL_MESSAGE}::text WHEN ${tooLateToStart} THEN ${DEADLINE_SIM_TOOL_MESSAGE}::text ELSE ${INTERRUPTED_SIM_TOOL_MESSAGE}::text END`
1139
1143
1140
1144
/**
1141
1145
* Whether one of the run's Sim handlers is still running with its execution lease held. Its
@@ -1192,7 +1196,7 @@ export async function revokeExhaustedSimToolExecutions(runId: string) {
'This tool call did not finish within its time limit and was abandoned. Its outcome is unknown: it may already have taken effect, so inspect the current state before repeating it.'
29
30
30
-
/**
31
-
* Whether the call's deadline has passed, so nothing more may start for it: no handler, approval
32
-
* wait, server fallback or allowed decision. A call without a deadline never passes one.
33
-
*/
31
+
/** Whether the call's deadline has passed. A call without a deadline never passes one. */
0 commit comments