Skip to content

Add Standalone Activities support to Temporal Nexus Operation Handler - #748

Merged
Quinn-With-Two-Ns merged 4 commits into
temporalio:mainfrom
Quinn-With-Two-Ns:NEXUS-389
Jul 24, 2026
Merged

Add Standalone Activities support to Temporal Nexus Operation Handler#748
Quinn-With-Two-Ns merged 4 commits into
temporalio:mainfrom
Quinn-With-Two-Ns:NEXUS-389

Conversation

@Quinn-With-Two-Ns

@Quinn-With-Two-Ns Quinn-With-Two-Ns commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What was changed

Add Standalone Activities support to Temporal Nexus Operation Handler

Why?

Allow calling Standalone Activities as a Nexus Operation

Checklist

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?

Note

Medium Risk
Touches experimental Nexus operation lifecycle (tokens, callbacks, cancel, link propagation) and extends standalone activity client RPC shaping; behavior is covered by new tests but cross-server link support may still vary.

Overview
Adds standalone activities as async Nexus operations via new ITemporalNexusClient.StartActivityAsync overloads (expression and by-name), with activity-execution operation tokens, completion callbacks, and idempotent start plumbing aligned with workflow-backed operations.

TemporalOperationHandler cancel now routes by token type and supports activity tokens; default cancel calls CancelAsync on the underlying activity, with an overridable CancelActivityExecutionAsync. StartActivityOptions gains internal fields for Nexus (request ID, links, callbacks, on-conflict options), and activity/workflow starts inside a Nexus handler attach outbound links from server responses (workflow start also falls back to a synthetic started-event link on older servers).

Shared Nexus start logic is factored into NexusOperationStartHelper; workflow docs now say task queue defaults to the operation queue when omitted. Activity proto links round-trip through ProtoLinkExtensions, and package-validation suppressions cover the new public API.

Reviewed by Cursor Bugbot for commit abff167. Bugbot is set up for automated code reviews on this repo. Configure here.

@Quinn-With-Two-Ns
Quinn-With-Two-Ns requested a review from a team as a code owner June 16, 2026 16:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f807fc513

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Temporalio/Nexus/TemporalOperationHandler.cs Outdated
Comment thread src/Temporalio/Nexus/NexusActivityStartHelper.cs
Comment thread src/Temporalio/Client/TemporalClient.Activity.cs
Comment thread src/Temporalio/Client/TemporalClient.Workflow.cs
@jmaeagle99 jmaeagle99 self-assigned this Jun 22, 2026
options.RequestId = nexusStartContext.RequestId;

// Do the start call
var handle = await client.StartActivityAsync(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In the Go implementation, we check for timeout presence to raise a handler error and surface the validation error. Is that necessary here as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The SDK already does some of this validation, Started a discussion in slack on where we want to do the validation.

Comment thread src/Temporalio/Nexus/TemporalOperationHandler.cs Outdated

@jmaeagle99 jmaeagle99 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.

Mostly rename requests and I think there is opportunity for unifying the token types or at least refactoring to be more symmetrical and untied from handles (which can all be deferred).

Comment thread src/Temporalio/Nexus/NexusActivityExecutionToken.cs Outdated
Comment thread src/Temporalio/Nexus/NexusOperationStartCommon.cs Outdated
Comment thread src/Temporalio/Nexus/NexusOperationStartCommon.cs Outdated
Comment thread src/Temporalio/Nexus/NexusWorkflowRunHandle.cs Outdated
Comment thread src/Temporalio/Nexus/NexusActivityStartHelper.cs Outdated
Comment thread src/Temporalio/Nexus/NexusOperationStartCommon.cs Outdated
try
{
token = NexusWorkflowRunHandle.ParseToken(context.OperationToken);
tokenType = NexusWorkflowRunHandle.LoadTokenType(context.OperationToken);

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.

I think the token parsing and related logic could use a refactor such that we use a discriminated union, something like:

[JsonPolymorphic(TypeDiscriminatorPropertyName = "t")]
[JsonDerivedType(typeof(WorkflowExecutionToken), 1)]
[JsonDerivedType(typeof(ActivityExecutionToken), 2)]
internal abstract record NexusOperationToken(string Namespace, int? Version);

Then when parsing the STJ, you'll get the exact token class out rather than having to pick out the t field yourself and then construct each type separately.

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.

I would be fine with deferring a refactor of this along with https://github.com/temporalio/sdk-dotnet/pull/748/changes/BASE..8520a4bcc34de23a824cf065f2e377f5f615a09b#r3477893944 as a separate change.

{
NexusWorkflowRunHandle.WorkflowRunOperationTokenType =>
CancelWorkflowRunAsync(
case NexusWorkflowRunHandle.WorkflowRunOperationTokenType:

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.

Looking at the naming of the this token and helper methods vs the new one for standalone activities, they feel very asymmetrical when they really share a lot in common. For example, I think that the workflow run operation token should be separated from the handle notion and standard on either the "run" or "execution" name for both token types.

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.

I would be fine with deferring a refactor on this along with https://github.com/temporalio/sdk-dotnet/pull/748/changes/BASE..8520a4bcc34de23a824cf065f2e377f5f615a09b#r3477886756 as a separate change.

Comment thread src/Temporalio/Client/TemporalClient.Workflow.cs
@jmaeagle99

Copy link
Copy Markdown
Contributor

I assume that ITemporalNexusClient is not meant for customers to actually implement but just for us to provide easy wire up of Temporal operations as Nexus operations. If that's the case, then the API breaks are fine. Run dotnet pack -c Debug /p:ApiCompatGenerateSuppressionFile=true from the repo root to update the API compat suppression file.

Comment thread src/Temporalio/Nexus/ProtoLinkExtensions.cs Outdated
Comment thread src/Temporalio/Client/TemporalClient.Activity.cs
Comment thread src/Temporalio/Nexus/TemporalNexusClient.cs
Comment thread src/Temporalio/Client/TemporalClient.Workflow.cs

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 5306faa. Configure here.

Comment thread src/Temporalio/Nexus/TemporalOperationHandler.cs
@Quinn-With-Two-Ns
Quinn-With-Two-Ns merged commit c45ca26 into temporalio:main Jul 24, 2026
16 checks passed
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.

3 participants