Skip to content

WorkerSessionOptions + ActivitySessionOptions -- Defining Sessions - #885

Open
Shivs11 wants to merge 32 commits into
mainfrom
sticky-activity-session-options
Open

Shivs11 wants to merge 32 commits into
mainfrom
sticky-activity-session-options

Conversation

@Shivs11

@Shivs11 Shivs11 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

What changed?

Why?
Workflow as Session: route a workflow's tasks to the worker it is bound to, keep that binding across resets and new runs, and let the server move workflows off a stopped multi-session worker.

Breaking changes
None. All new fields are experimental.

Server PR
(still cooking)

Comment thread temporal/api/session/v1/message.proto Resolved
Comment thread temporal/api/session/v1/message.proto Resolved
Comment thread temporal/api/session/v1/message.proto Resolved
THardy98 and others added 2 commits October 23, 2026 16:59
<!-- Describe what has changed in this PR -->
**What changed?**
Basically just a single field change and some comment changes based on a
Notion doc proposal.

<!-- Tell your future self why have you made these changes -->
**Why?**


<!-- Are there any breaking changes on binary or code level? -->
**Breaking changes**


<!-- If this breaks the Server, please provide the Server PR to merge
right after this PR was merged. -->
**Server PR**

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
THardy98 added a commit to temporalio/sdk-python that referenced this pull request Oct 28, 2026
Pin Core to the rebased session stack (temporalio/sdk-rust#1687 at
ae440be3), which adopts temporalio/api#885 at d183f54c. Regenerate the
Python protos and encode workflow-session placement as the
`workflow_session` Empty field instead of the old bool, which a server
built on the new API would otherwise ignore.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
SDKs (Core) already reject an empty SingleSessionOptions.stable_identity;
state the requirement on the field so servers and other SDKs see it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
THardy98 added a commit to temporalio/sdk-python that referenced this pull request Oct 28, 2026
Pin Core to the session stack (temporalio/sdk-rust#1687 at 59f8a8f7),
which adopts the session API from temporalio/api#885, regenerate the Python
protos, refresh the bridge lockfile, and import Core's release notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Shivs11 Shivs11 changed the title Sticky activity session options WorkerSessionOptions + ActivitySessionOptions -- Defining Sessions Oct 28, 2026
THardy98 added a commit to temporalio/sdk-python that referenced this pull request Oct 28, 2026
Pin Core to the session stack (temporalio/sdk-rust#1687 at 6e88cb53),
which adopts the session API from temporalio/api#885, regenerate the Python
protos, refresh the bridge lockfile, and import Core's release notes.
Shivs11 and others added 2 commits November 17, 2026 10:15
api main took field 11 on PollWorkflowTaskQueueRequest and
PollActivityTaskQueueRequest for poller_pool_info.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shivs11 and others added 7 commits November 24, 2026 15:44
…y queue

A multi-session worker's sticky queue is named after its worker_instance_key,
so MultiSessionOptions carries no address. Single-session keeps stable_identity.
Exactly one admission mode is required.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
…rkerInfo

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shivs11 and others added 3 commits November 24, 2026 15:51
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…stance key

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shivs11 and others added 2 commits November 24, 2026 16:07
The worker queue is the only worker field the binding needs: a multi-session
worker's queue is its instance key, and a single-session binding never moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Shivs11
Shivs11 marked this pull request as ready for review November 24, 2026 21:37
@Shivs11
Shivs11 requested review from a team November 24, 2026 21:37
Shivs11 and others added 3 commits November 24, 2026 16:38
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unset means unbound, {} a multi-session binding, {exclusive_worker: true} a
single-session binding. The worker queue comes from the workflow task's
scheduled event.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Sushisource
Sushisource self-requested a review November 25, 2026 01:18

@Sushisource Sushisource left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use the word "service" rather than "serve" in the context of "the worker serves a session" as I think it's a little more clear that it means the worker is responsible for handling that session(s)

Comment thread temporal/api/history/v1/message.proto Outdated
// 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't cron be called schedule?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, forgot that we discourage crons now. i think, for now, shall be removing the use of either schedules/crons over here since we have not decided internally if we wanna support the inheritance of session options to those type of runs.

For example, in the world of versioning, we allowed versioning related fields to be set for CAN workflows but not crons/schedules. Shall come back to this and then later edit the comment if we decide that we wanna support this.

Comment thread temporal/api/session/v1/message.proto Outdated
// concurrently, the server treats them as pollers of a single worker and
// process affinity is lost.
//
// Note: this effectively acts as a configurable sticky queue.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear what "configurable" sticky queue means

@THardy98 THardy98 Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a sticky queue that can be named/specified by the user

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going to change the comment to say what thomas responded here.

Comment thread temporal/api/session/v1/message.proto Outdated
Comment on lines +77 to +82
// server can rebuild the binding from history (for example on reset). See
// session_info on WorkflowTaskStartedEventAttributes and inherited_session_info
// on WorkflowExecutionStartedEventAttributes:
// * unset: not bound (started by a worker without sessions).
// * {}: bound to a multi-session worker.
// * {exclusive_worker: true}: bound to a single-session worker.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all these semantics belong on the fields use this type. No need to refer to the fields that use it, either. IDEs will tell you where a type is used just fine.

Shivs11 and others added 3 commits November 25, 2026 12:17
…drop cron

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shivs11 and others added 2 commits November 25, 2026 15:40
**What changed?**
`SessionInfo.worker_queue`: the sticky queue of the worker a workflow is
bound to (stable identity for single-session, worker instance key for
multi-session).

**Why?**
History has no other record of the bound worker's queue: the workflow
task that binds a worker is scheduled on the normal queue, the
started/completed events carry no queue, and the started event's
`task_queue` is the workflow's normal queue that SDKs read. Without it,
a reset to the binding task or a continue-as-new/retry rebuild loses the
binding. Written only on history events; read only when the server
rebuilds state from them.

**Breaking changes**
None. New experimental field on top of #885.

**Server PR**
To follow, with the session stack.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A workflow with session activities waiting for a session worker can only have its workflow tasks completed by a
worker servicing sessions; the server fails a completion from any other worker with this cause.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ShahabT ShahabT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants