diff --git a/temporalio/nexus/_operation_context.py b/temporalio/nexus/_operation_context.py index 06ffd9b0f..4d444967a 100644 --- a/temporalio/nexus/_operation_context.py +++ b/temporalio/nexus/_operation_context.py @@ -776,15 +776,15 @@ def _apply_nexus_context_to_start_activity_request( # pyright: ignore[reportUnu req.on_conflict_options.attach_completion_callbacks = True req.on_conflict_options.attach_links = True - # Add request_id and all Nexus links if we're in a Nexus context, backing or otherwise - req.request_id = nexus_ctx.nexus_context.request_id + # Add all Nexus links if we're in a Nexus context, backing or otherwise request_links = nexus_ctx._get_request_links() # Links are duplicated on request for compatibility with older server versions. req.links.extend(request_links) if _in_nexus_backing_start_context(): - # Add callbacks only if we're in a backing Nexus context + # Add request_id and callbacks only if we're in a backing Nexus context + req.request_id = nexus_ctx.nexus_context.request_id callbacks = nexus_ctx._get_callbacks( OperationToken( type=OperationTokenType.ACTIVITY, diff --git a/tests/nexus/test_link_propagation.py b/tests/nexus/test_link_propagation.py index 2c9f6eec7..d30d092ec 100644 --- a/tests/nexus/test_link_propagation.py +++ b/tests/nexus/test_link_propagation.py @@ -496,7 +496,7 @@ async def test_activity_start_forwards_inbound_links() -> None: assert len(req.links) == 1 assert req.links[0] == _inbound_nexus_link() - assert req.request_id == "req-id" + assert not req.request_id assert len(req.completion_callbacks) == 0