Skip to content

Add original execution IDs to Temporal workflow spans - #958

Open
Ehsan-hash wants to merge 3 commits into
braintrustdata:mainfrom
Ehsan-hash:feature/temporal-original-run-metadata
Open

Ehsan-hash wants to merge 3 commits into
braintrustdata:mainfrom
Ehsan-hash:feature/temporal-original-run-metadata

Conversation

@Ehsan-hash

Copy link
Copy Markdown

Temporal resets create a new run ID, which makes related workflow traces hard to connect. Workflow spans now include temporal.original_execution_run_id when the Temporal SDK exposes it. Current temporal.run_id and run-based span identities remain separate, and older supported SDK versions omit the unavailable field.

Closes #868.

Validation on Python 3.14.7:

  • Regressions fail on the original code with the missing metadata field.
  • Full pinned Temporal matrix: 1.34.0, 11 passed; 1.20.0 and 1.19.0, 10 passed and one feature-specific skip each.
  • A real local Temporal reset produces distinct run IDs, preserves the original execution ID on both workflow spans, and keeps separate span IDs and activity parents. This uses the SDK's standard local development server because its lightweight test server does not implement resets.
  • Required make fixup, scoped Ruff and git diff --check pass. Fresh independent review covers both changed files.

The tests use synthetic local workflows and an in-memory logger. No live Braintrust account, provider model, new cassette recording, dependency or release change is involved. The full Python/provider matrix was not run locally.

AI-assisted with Codex: gpt-6.1-sol/high for integration, gpt-5.6-luna/high for implementation and gpt-5.6-sol/high for independent review.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T17:11:24.436883Z 5088168 PR opened
ℹ️ About Codex in GitHub

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

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.


@pytest_asyncio.fixture
async def temporal_local_env():
"""Create a full local Temporal server for capabilities absent from the test 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.

this doesn't seem right, why do we have it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The new reset regression test uses this fixture because WorkflowEnvironment.start_time_skipping() returns UNIMPLEMENTED for ResetWorkflowExecution. start_local() provides that RPC without a hosted Temporal service.

The test performs a real reset so the original execution ID differs from the current run ID. That distinction catches accidentally recording run_id as original_execution_run_id, which an ordinary run would miss. The existing tests still use temporal_env; only this reset test starts the local 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.

hmm, i wonder if we can better consolidate the tests then?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Consolidated the setup into the existing temporal_env fixture. Ordinary tests still use the time-skipping server; only the reset test selects the local server through indirect parametrization. Both modes now share the download cache setup, with the appropriate TTL option for each server.

The real reset assertions are unchanged. The full Temporal matrix passes: 1.34.0 has 11 passes; 1.20.0 and 1.19.0 each have 10 passes and one expected skip for the unavailable metadata field. make fixup and independent review also pass.

@Ehsan-hash

Copy link
Copy Markdown
Author

The remaining Windows Python 3.11 shard-2 failure occurs during dependency installation for test_transformers(4.42.0): the request to https://download.pytorch.org/whl/cpu/fsspec/ times out after three retries. The same job reports successful test_temporal(1.19.0) and test_temporal(latest) sessions.

The aggregate checks-passed failure follows that shard failure. I have not changed source or tests for the external download timeout.

This branch has not been deployed

No deployments
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.

Temporal: add workflow.Info.original_execution_run_id to workflow span metadata

2 participants