Skip to content

Improve replay-safety documentation for interceptors, clarify where interceptors run.#4307

Merged
lennessyy merged 18 commits intomainfrom
drewhoskins_interceptor
Mar 23, 2026
Merged

Improve replay-safety documentation for interceptors, clarify where interceptors run.#4307
lennessyy merged 18 commits intomainfrom
drewhoskins_interceptor

Conversation

@drewhoskins-temporal
Copy link
Copy Markdown
Contributor

@drewhoskins-temporal drewhoskins-temporal commented Mar 19, 2026

What does this PR do?

We're trying to improve our interceptor docs for our AI Partner program. Interceptors are hard, we're trying to make it easier.

  • Link interceptor docs to advice about determinism, which comes up a lot in interceptors.
  • Improve docs about determinism per-language
  • Also link to these docs from the encyclopedia.

Notes to reviewers

Main Claude Prompt:

First of all, we need to talk about workflow determinism. Interceptors need to be aware of workflow replays. There are some key techniques to present. 1. "is replaying" 2. generation of stable random numbers using newRandom or equivalent. 3. using the builtin logger, 4. time. We don't have great existing docs for all of those things, and they aren't exclusive to interceptors, though they come up in particular when writing interceptors. What I'd like to see is a separate section to aggregate all those topics for each language, and then flag replay determinism in the interceptor docs and deep link to those.

Test plan:

yarn start

click in all the docs
http://localhost:3000/develop/java/core-application#workflow-logic-requirements
http://localhost:3000/develop/dotnet/core-application#workflow-logic-requirements
http://localhost:3000/develop/python/core-application#workflow-logic-requirements
http://localhost:3000/develop/java/core-application#workflow-logic-requirements
http://localhost:3000/develop/go/core-application#workflow-logic-requirements
http://localhost:3000/develop/dotnet/core-application#workflow-logic-requirements

┆Attachments: EDU-6066 Improve replay-safety documentation for interceptors

@drewhoskins-temporal drewhoskins-temporal requested a review from a team as a code owner March 19, 2026 05:17
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
temporal-documentation Ready Ready Preview, Comment Mar 23, 2026 11:54pm

Request Review

current_time = workflow.now()
```

#### Detecting replay (advanced)
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.

This is probably the right place to also elaborate on workflow.unsafe.is_replaying_history_events

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.

It doesn't seem to be in every SDK yet but I can add to the ones it's in. If you can ping the person who's implementing these to know to come update the docs, that'd be great.

Comment thread docs/develop/python/interceptors.mdx
Comment thread docs/develop/python/interceptors.mdx Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 19, 2026

📖 Docs PR preview links

@drewhoskins-temporal drewhoskins-temporal changed the title Improve replay-safety documentation for interceptors Improve replay-safety documentation for interceptors, clarify where interceptors run. Mar 19, 2026
Copy link
Copy Markdown
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

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

Review of Ruby section

Comment thread docs/develop/ruby/core-application.mdx Outdated
Copy link
Copy Markdown
Contributor

@jmaeagle99 jmaeagle99 left a comment

Choose a reason for hiding this comment

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

Feedback on improving links for .NET. Also, there is no interceptors docs for .NET, but looks like we have an issue for it already: #3875

Comment thread docs/develop/dotnet/core-application.mdx Outdated
Comment thread docs/develop/dotnet/core-application.mdx Outdated
Comment thread docs/develop/dotnet/core-application.mdx Outdated
Copy link
Copy Markdown
Contributor

@yuandrew yuandrew left a comment

Choose a reason for hiding this comment

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

go looks fine

drewhoskins-temporal and others added 2 commits March 20, 2026 17:01
Co-authored-by: Justin Anderson <44687433+jmaeagle99@users.noreply.github.com>
Co-authored-by: Justin Anderson <44687433+jmaeagle99@users.noreply.github.com>
Co-authored-by: Justin Anderson <44687433+jmaeagle99@users.noreply.github.com>
Comment thread docs/develop/go/core-application.mdx Outdated
#### Detecting replay (advanced)

Use [`workflow.IsReplaying(ctx)`](https://pkg.go.dev/go.temporal.io/sdk/workflow#IsReplaying) to guard code that should only run on the first execution, such as emitting metrics or sending external notifications from an Interceptor.
(Never use this to affect Workflow business logic - branching on replay status breaks determinism.)
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'd put this in a Caution box instead

Comment thread docs/develop/java/core-application.mdx Outdated
#### Detecting replay (advanced)

Use [`WorkflowUnsafe.isReplaying()`](https://www.javadoc.io/doc/io.temporal/temporal-sdk/latest/io/temporal/workflow/WorkflowUnsafe.html) to guard code that should only run on the first execution, such as emitting metrics or sending external notifications from an Interceptor.
(Never use this to affect Workflow business logic - branching on replay status breaks determinism.)
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.

Same here for the rest of the SDKs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lennessyy lennessyy merged commit fa2cdd4 into main Mar 23, 2026
10 checks passed
@lennessyy lennessyy deleted the drewhoskins_interceptor branch March 23, 2026 23:58
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.

8 participants