From 44a8edf8446c4e835c1b3f5c76f54b9c046b0537 Mon Sep 17 00:00:00 2001 From: Shivam Saraf Date: Fri, 20 Nov 2026 16:31:34 -0500 Subject: [PATCH 1/2] Record a workflow's session info on history events Adds SessionInfo (exclusive_worker, bound_worker_info) in session/v1 and records it on WorkflowTaskStartedEventAttributes (session_info) and WorkflowExecutionStartedEventAttributes (inherited_session_info), so the server can rebuild a workflow's worker binding from history, for example on reset. Co-Authored-By: Claude Opus 5.5 --- openapi/openapiv2.json | 32 +++++++++++++++++ openapi/openapiv3.yaml | 49 +++++++++++++++++++++++++++ temporal/api/history/v1/message.proto | 12 +++++++ temporal/api/session/v1/message.proto | 27 +++++++++++++++ 4 files changed, 120 insertions(+) diff --git a/openapi/openapiv2.json b/openapi/openapiv2.json index 7a8c0da69..2b44675b7 100644 --- a/openapi/openapiv2.json +++ b/openapi/openapiv2.json @@ -14804,6 +14804,16 @@ }, "description": "BatchOperationUpdateWorkflowExecutionOptions sends UpdateWorkflowExecutionOptions requests to batch workflows.\nKeep the parameters in sync with temporal.api.workflowservice.v1.UpdateWorkflowExecutionOptionsRequest." }, + "v1BoundWorkerInfo": { + "type": "object", + "properties": { + "workerQueue": { + "type": "string", + "description": "The worker's queue: the stable identity of a single-session worker, or\nthe worker address of a multi-session worker. The workflow's tasks are\nrouted here.\n\nmore fields may be added later, such as the worker's instance key so that\n history can send it to matching to understand if the worker's heartbeating\n information." + } + }, + "description": "EXPERIMENTAL. Subject to redesign or removal.\nThe worker a workflow is bound to. Recorded by the server." + }, "v1BuildIdAssignmentRule": { "type": "object", "properties": { @@ -19927,6 +19937,20 @@ } } }, + "v1SessionInfo": { + "type": "object", + "properties": { + "exclusiveWorker": { + "type": "boolean", + "description": "True when the workflow is bound to a single-session worker. Such a\nbinding never moves to another worker. False for a multi-session worker,\nwhose binding moves with the worker that starts the workflow's tasks." + }, + "boundWorkerInfo": { + "$ref": "#/definitions/v1BoundWorkerInfo", + "description": "The worker the workflow is bound to. Always set." + } + }, + "description": "EXPERIMENTAL. Subject to redesign or removal.\nWhich worker a workflow (which is the session) is bound to. The server records it on history events\nso it can rebuild the binding from history (for example on reset). See\nsession_info on WorkflowTaskStartedEventAttributes and inherited_session_info\non WorkflowExecutionStartedEventAttributes. Not a worker or user option; SDKs\nshould not read or interpret it." + }, "v1SetCurrentDeploymentResponse": { "type": "object", "properties": { @@ -22376,6 +22400,10 @@ "propagatedNexusSerializationContext": { "$ref": "#/definitions/v1PropagatedSerializationContext", "description": "Serialization context propagated from the Nexus caller that started this workflow." + }, + "inheritedSessionInfo": { + "$ref": "#/definitions/v1SessionInfo", + "description": "Session info this run inherited from the previous run (continue-as-new, retry or cron), so the server\ncan rebuild it from history. Nil when the previous run was not bound or this run is on a different\ntask queue. Child workflows never inherit it.\nUsed internally by the server; SDKs should not read or interpret this field.\nEXPERIMENTAL. Subject to redesign or removal." } }, "title": "Always the first event in workflow history" @@ -22967,6 +22995,10 @@ "type": "string", "format": "int64", "title": "Used by server internally to properly reapply build ID redirects to an execution\nwhen rebuilding it from events.\nDeprecated. This field should be cleaned up when versioning-2 API is removed. [cleanup-experimental-wv]" + }, + "sessionInfo": { + "$ref": "#/definitions/v1SessionInfo", + "description": "Session info of this workflow as of this task start, so the server can rebuild it from history (for\nexample on reset). Nil when the workflow is not bound to a worker.\nUsed internally by the server; SDKs should not read or interpret this field.\nEXPERIMENTAL. Subject to redesign or removal." } } }, diff --git a/openapi/openapiv3.yaml b/openapi/openapiv3.yaml index d7f79afe3..7e7cfeff9 100644 --- a/openapi/openapiv3.yaml +++ b/openapi/openapiv3.yaml @@ -10757,6 +10757,18 @@ components: description: |- BatchOperationUpdateWorkflowExecutionOptions sends UpdateWorkflowExecutionOptions requests to batch workflows. Keep the parameters in sync with temporal.api.workflowservice.v1.UpdateWorkflowExecutionOptionsRequest. + BoundWorkerInfo: + type: object + properties: + workerQueue: + type: string + description: |- + The worker's queue: the stable identity of a single-session worker, or + the worker address of a multi-session worker. The workflow's tasks are + routed here. + description: |- + EXPERIMENTAL. Subject to redesign or removal. + The worker a workflow is bound to. Recorded by the server. BuildIdAssignmentRule: type: object properties: @@ -16811,6 +16823,26 @@ components: properties: nonRetryable: type: boolean + SessionInfo: + type: object + properties: + exclusiveWorker: + type: boolean + description: |- + True when the workflow is bound to a single-session worker. Such a + binding never moves to another worker. False for a multi-session worker, + whose binding moves with the worker that starts the workflow's tasks. + boundWorkerInfo: + allOf: + - $ref: '#/components/schemas/BoundWorkerInfo' + description: The worker the workflow is bound to. Always set. + description: |- + EXPERIMENTAL. Subject to redesign or removal. + Which worker a workflow (which is the session) is bound to. The server records it on history events + so it can rebuild the binding from history (for example on reset). See + session_info on WorkflowTaskStartedEventAttributes and inherited_session_info + on WorkflowExecutionStartedEventAttributes. Not a worker or user option; SDKs + should not read or interpret it. SetCurrentDeploymentRequest: type: object properties: @@ -21042,6 +21074,15 @@ components: allOf: - $ref: '#/components/schemas/PropagatedSerializationContext' description: Serialization context propagated from the Nexus caller that started this workflow. + inheritedSessionInfo: + allOf: + - $ref: '#/components/schemas/SessionInfo' + description: |- + Session info this run inherited from the previous run (continue-as-new, retry or cron), so the server + can rebuild it from history. Nil when the previous run was not bound or this run is on a different + task queue. Child workflows never inherit it. + Used internally by the server; SDKs should not read or interpret this field. + EXPERIMENTAL. Subject to redesign or removal. description: Always the first event in workflow history WorkflowExecutionTerminatedEventAttributes: type: object @@ -21722,6 +21763,14 @@ components: Used by server internally to properly reapply build ID redirects to an execution when rebuilding it from events. Deprecated. This field should be cleaned up when versioning-2 API is removed. [cleanup-experimental-wv] + sessionInfo: + allOf: + - $ref: '#/components/schemas/SessionInfo' + description: |- + Session info of this workflow as of this task start, so the server can rebuild it from history (for + example on reset). Nil when the workflow is not bound to a worker. + Used internally by the server; SDKs should not read or interpret this field. + EXPERIMENTAL. Subject to redesign or removal. WorkflowTaskTimedOutEventAttributes: type: object properties: diff --git a/temporal/api/history/v1/message.proto b/temporal/api/history/v1/message.proto index 96628ab87..5de25065c 100644 --- a/temporal/api/history/v1/message.proto +++ b/temporal/api/history/v1/message.proto @@ -219,6 +219,13 @@ message WorkflowExecutionStartedEventAttributes { // Serialization context propagated from the Nexus caller that started this workflow. temporal.api.nexus.v1.PropagatedSerializationContext propagated_nexus_serialization_context = 44; + + // Session info this run inherited from the previous run (continue-as-new, retry or cron), so the server + // can rebuild it from history. Nil when the previous run was not bound or this run is on a different + // task queue. Child workflows never inherit it. + // Used internally by the server; SDKs should not read or interpret this field. + // EXPERIMENTAL. Subject to redesign or removal. + temporal.api.session.v1.SessionInfo inherited_session_info = 45; } @@ -342,6 +349,11 @@ message WorkflowTaskStartedEventAttributes { // when rebuilding it from events. // Deprecated. This field should be cleaned up when versioning-2 API is removed. [cleanup-experimental-wv] int64 build_id_redirect_counter = 7 [deprecated = true]; + // Session info of this workflow as of this task start, so the server can rebuild it from history (for + // example on reset). Nil when the workflow is not bound to a worker. + // Used internally by the server; SDKs should not read or interpret this field. + // EXPERIMENTAL. Subject to redesign or removal. + temporal.api.session.v1.SessionInfo session_info = 10; } message WorkflowTaskCompletedEventAttributes { diff --git a/temporal/api/session/v1/message.proto b/temporal/api/session/v1/message.proto index ef59aeada..bfc00cecd 100644 --- a/temporal/api/session/v1/message.proto +++ b/temporal/api/session/v1/message.proto @@ -67,3 +67,30 @@ message ActivitySessionOptions { // Future: references to other types of sessions. } } + +// EXPERIMENTAL. Subject to redesign or removal. +// Which worker a workflow (which is the session) is bound to. The server records it on history events +// so it can rebuild the binding from history (for example on reset). See +// session_info on WorkflowTaskStartedEventAttributes and inherited_session_info +// on WorkflowExecutionStartedEventAttributes. Not a worker or user option; SDKs +// should not read or interpret it. +message SessionInfo { + // True when the workflow is bound to a single-session worker. Such a + // binding never moves to another worker. False for a multi-session worker, + // whose binding moves with the worker that starts the workflow's tasks. + bool exclusive_worker = 1; + // The worker the workflow is bound to. Always set. + BoundWorkerInfo bound_worker_info = 2; +} + +// EXPERIMENTAL. Subject to redesign or removal. +// The worker a workflow is bound to. Recorded by the server. +message BoundWorkerInfo { + // The worker's queue: the stable identity of a single-session worker, or + // the worker address of a multi-session worker. The workflow's tasks are + // routed here. + string worker_queue = 1; + // more fields may be added later, such as the worker's instance key so that + // history can send it to matching to understand if the worker's heartbeating + // information. +} From 3675bef786c0e1c3aca64e240645516b8fae0c34 Mon Sep 17 00:00:00 2001 From: Shivam Saraf Date: Tue, 24 Nov 2026 12:40:06 -0500 Subject: [PATCH 2/2] Move BoundWorkerInfo's future-fields note into its doc comment for api-linter --- openapi/openapiv2.json | 4 ++-- openapi/openapiv3.yaml | 4 +++- temporal/api/session/v1/message.proto | 7 +++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/openapi/openapiv2.json b/openapi/openapiv2.json index 2b44675b7..59608b893 100644 --- a/openapi/openapiv2.json +++ b/openapi/openapiv2.json @@ -14809,10 +14809,10 @@ "properties": { "workerQueue": { "type": "string", - "description": "The worker's queue: the stable identity of a single-session worker, or\nthe worker address of a multi-session worker. The workflow's tasks are\nrouted here.\n\nmore fields may be added later, such as the worker's instance key so that\n history can send it to matching to understand if the worker's heartbeating\n information." + "description": "The worker's queue: the stable identity of a single-session worker, or\nthe worker address of a multi-session worker. The workflow's tasks are\nrouted here." } }, - "description": "EXPERIMENTAL. Subject to redesign or removal.\nThe worker a workflow is bound to. Recorded by the server." + "description": "EXPERIMENTAL. Subject to redesign or removal.\nThe worker a workflow is bound to. Recorded by the server. More fields may be\nadded later, such as the worker's instance key so that history can send it to\nmatching to understand if the worker's heartbeating information." }, "v1BuildIdAssignmentRule": { "type": "object", diff --git a/openapi/openapiv3.yaml b/openapi/openapiv3.yaml index 7e7cfeff9..c7beb4f98 100644 --- a/openapi/openapiv3.yaml +++ b/openapi/openapiv3.yaml @@ -10768,7 +10768,9 @@ components: routed here. description: |- EXPERIMENTAL. Subject to redesign or removal. - The worker a workflow is bound to. Recorded by the server. + The worker a workflow is bound to. Recorded by the server. More fields may be + added later, such as the worker's instance key so that history can send it to + matching to understand if the worker's heartbeating information. BuildIdAssignmentRule: type: object properties: diff --git a/temporal/api/session/v1/message.proto b/temporal/api/session/v1/message.proto index bfc00cecd..e700fa6ae 100644 --- a/temporal/api/session/v1/message.proto +++ b/temporal/api/session/v1/message.proto @@ -84,13 +84,12 @@ message SessionInfo { } // EXPERIMENTAL. Subject to redesign or removal. -// The worker a workflow is bound to. Recorded by the server. +// The worker a workflow is bound to. Recorded by the server. More fields may be +// added later, such as the worker's instance key so that history can send it to +// matching to understand if the worker's heartbeating information. message BoundWorkerInfo { // The worker's queue: the stable identity of a single-session worker, or // the worker address of a multi-session worker. The workflow's tasks are // routed here. string worker_queue = 1; - // more fields may be added later, such as the worker's instance key so that - // history can send it to matching to understand if the worker's heartbeating - // information. }