Skip to content

Add support for setting ActivityID - #3044

Open
Quinn-With-Two-Ns wants to merge 1 commit into
temporalio:mainfrom
Quinn-With-Two-Ns:SDK-853
Open

Add support for setting ActivityID#3044
Quinn-With-Two-Ns wants to merge 1 commit into
temporalio:mainfrom
Quinn-With-Two-Ns:SDK-853

Conversation

@Quinn-With-Two-Ns

@Quinn-With-Two-Ns Quinn-With-Two-Ns commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

What was changed

Add support for setting ActivityID

Why?

Add support for setting ActivityID, for manual completion or deduplication.

Checklist

  1. Closes Support passing activityId to an activity invocation #86

  2. How was this tested:

  1. Any docs updates needed?

Note

Medium Risk
Changes the core activity scheduling and replay path; incorrect or non-deterministic activity IDs can break workflow replay or violate uniqueness among open activities.

Overview
Adds experimental per-call control over Activity and Local Activity scheduling via ActivityInvocationOptions, chiefly setActivityId for deduplication and async completion scenarios.

Workflow code can use Workflow.executeActivity / executeActivityAsync (typed method references) or ActivityStub overloads that take ActivityInvocationOptions. Optional setActivityOptions replaces stub options for that single remote activity only; local activities reject that field. When no ID is set, behavior stays the same (server/SDK-generated IDs).

Internally, ActivityInvocationInternal uses a thread-local so one options object applies to exactly one stub call inside the lambda. The optional ID flows through WorkflowOutboundCallsInterceptor.ActivityInput / LocalActivityInput into SyncWorkflowContext, which sets activity_id on schedule commands and preserves it across local-activity retries. Package docs and integration tests cover history, concurrency, option overrides, and replay when the explicit ID is stable vs changed.

Reviewed by Cursor Bugbot for commit 01d2725. 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 August 28, 2026 16:01

@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: 01d272538a

ℹ️ 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 on lines +23 to +25
try {
invocationFunction.apply();
return state.getResult();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve transformations performed by activity lambdas

When the supplied function is a lambda that transforms the activity result, such as () -> activities.getNumber() + 1, the proxy captures the underlying Activity Promise but returns a default value to the lambda; this call then discards the lambda's computed result and returns the captured promise unchecked. Consequently the example resolves to the raw Activity value rather than the incremented value, and lambdas that dereference object results can throw NullPointerException. Either preserve the function's result semantics or reject anything other than a direct Activity invocation.

Useful? React with 👍 / 👎.

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.

Support passing activityId to an activity invocation

1 participant