fix(server): working timers no longer reset on every background wake (#15029)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
9333509c91
commit
736130c2fd
9 files changed
+245
-11
No files matched your search
@@ -528,6 +528,12 @@ export const OrchestrationV2Run = Schema.Struct({
|
||||
contextHandoffId: Schema.NullOr(ContextHandoffId),
|
||||
/** Links server-generated restart continuations to the interrupted run. */
|
||||
restartContinuationOfRunId: Schema.optional(RunId),
|
||||
/**
|
||||
* Set on wake runs (background notifications, delegated task results,
|
||||
* restart continuations): when the work they continue started. Read it
|
||||
* through orchestrationV2RunWorkStartedAt.
|
||||
*/
|
||||
workStartedAt: Schema.optional(Schema.DateTimeUtc),
|
||||
/**
|
||||
* Set by restart recovery on the thread's latest started run. Delivered to
|
||||
* the provider with the first later run that reaches a provider turn.
|
||||
@@ -545,6 +551,16 @@ export const OrchestrationV2Run = Schema.Struct({
|
||||
});
|
||||
export type OrchestrationV2Run = typeof OrchestrationV2Run.Type;
|
||||
|
||||
/**
|
||||
* When the work a run belongs to started. A wake does not start new work, so
|
||||
* working timers count from the prompt that did, not from the latest wake.
|
||||
*/
|
||||
export function orchestrationV2RunWorkStartedAt(
|
||||
run: Pick<OrchestrationV2Run, "workStartedAt" | "startedAt" | "requestedAt">,
|
||||
): OrchestrationV2Run["requestedAt"] {
|
||||
return run.workStartedAt ?? run.startedAt ?? run.requestedAt;
|
||||
}
|
||||
|
||||
export const OrchestrationV2RunAttempt = Schema.Struct({
|
||||
id: RunAttemptId,
|
||||
// Provider-thread rows can be reused after recovery; retain the native input destination.
|
||||
@@ -1688,7 +1704,10 @@ export const OrchestrationV2ThreadShell = Schema.Struct({
|
||||
latestRunStartedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtc)),
|
||||
latestRunCompletedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtc)),
|
||||
activeRunId: Schema.NullOr(RunId),
|
||||
/** Start of the activity-owning run; request time while it is preparing. */
|
||||
/**
|
||||
* orchestrationV2RunWorkStartedAt of the activity-owning run: a wake keeps
|
||||
* the start of the work it continues; request time while preparing.
|
||||
*/
|
||||
activityRunStartedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtc)),
|
||||
activityRunStatus: Schema.optional(
|
||||
Schema.NullOr(Schema.Literals(["preparing", "starting", "running", "waiting"])),
|
||||
@@ -1841,6 +1860,7 @@ export const OrchestrationV2RunJson = OrchestrationV2Run.mapFields((fields) => (
|
||||
requestedAt: Schema.DateTimeUtcFromString,
|
||||
startedAt: Schema.NullOr(Schema.DateTimeUtcFromString),
|
||||
completedAt: Schema.NullOr(Schema.DateTimeUtcFromString),
|
||||
workStartedAt: Schema.optional(Schema.DateTimeUtcFromString),
|
||||
}));
|
||||
export type OrchestrationV2RunJson = typeof OrchestrationV2RunJson.Type;
|
||||
|
||||
|
||||
Reference in new issue
Block a user