Skip to content

fix(openai_agents): preserve propagated traces with OpenInference 2.6 - #447

Merged
brianstrauch merged 2 commits into
fix/python-pytest-9-2from
fix/openai-agents-openinference-444
Nov 12, 2026
Merged

brianstrauch merged 2 commits into
fix/python-pytest-9-2from
fix/openai-agents-openinference-444

Conversation

@brianstrauch

@brianstrauch brianstrauch commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Depends on #487 for the shared pytest 9.2 and pytest-asyncio migration. This PR contains only the OpenInference tracing fix, regression tests, and README note.

OpenInference 2.6 rejects workflow and activity spans when their trace root is owned by another processor or has already ended. Adapt explicitly propagated Temporal context using a scoped non-recording parent so workers retain the caller's trace, parent, and sampling settings without emitting duplicate roots.

Attach callbacks to each processor instance so draining processors retain span ownership and context cleanup across re-instrumentation. Delegate the SDK processor tuple and lock through Temporal's wrapper so OpenInference's registration and removal reach the actual processors. Dependency constraints remain uncapped.

Regression coverage includes a separate client process, worker restarts, concurrent remote parents, sampling, and processor draining.

Validation of this branch stacked on #487, on macOS / Python 3.14:

  • Locked dependencies, including OpenInference 2.2: 602 tests passed; one 2.6-specific draining test skipped.
  • Latest allowed dependencies, including OpenInference 2.6 and Temporal SDK 1.35: all 603 tests passed.
  • make lint passes with both dependency sets.
  • The two tracing commits are unchanged by the rebase, verified with git range-diff. The committed lockfile is restored after latest-dependency validation.

Addresses #444; the automated nightly issue remains open until a green latest-dependency run closes it.

@brianstrauch
brianstrauch force-pushed the fix/openai-agents-openinference-444 branch from 3981c9b to 11730f0 Compare November 11, 2026 16:45
@brianstrauch
brianstrauch changed the base branch from main to fix/python-pytest-9-2 November 11, 2026 16:46

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

LGTM!

@brianstrauch
brianstrauch merged commit 1fc80db into fix/python-pytest-9-2 Nov 12, 2026
101 checks passed
@brianstrauch
brianstrauch deleted the fix/openai-agents-openinference-444 branch November 12, 2026 19:18
brianstrauch added a commit that referenced this pull request Nov 12, 2026
Pytest 9.2 removed fixture-manager internals used by pytest-asyncio
0.21, causing nightly tests to fail during collection. Upgrade all 11
Python plugins and the plugin template to pytest >=9.2,<10 and
pytest-asyncio >=1.4.1,<2.

Replace custom event_loop fixtures with pytest-asyncio's session loop
configuration so Temporal's session-scoped environment, async fixtures,
and tests continue sharing one loop. Remove obsolete untyped-decorator
suppressions and the Google GenAI pytest cap. Every Python minimum and
runtime dependency remains unchanged; lockfile version changes are
limited to pytest, pytest-asyncio, and its Python 3.10 asyncio runner
backport.

Validation:
- make sync, make lint, and make test PYTEST_ARGS="-n 2 -q" pass for all
11 plugins on Python 3.14: 2,459 tests passed.
- MCP also passes all 130 tests on Python 3.10.
- Repository conventions and all 519 tooling tests pass.

This is the base for #447, which retains the OpenInference tracing
changes. Addresses #476, #477, #479, #480, #481, #482, #483, and #484;
their automated nightly issues remain open until a green
latest-dependency run closes them.
campoy added a commit that referenced this pull request Nov 13, 2026
## What was changed

- `LangSmithPlugin` and `LangSmithInterceptor` take an `AgentAddress`
and check it with `langsmith.address.ensure_agent`. On LangSmith older
than 0.14.10, `address=` raises a clear error. Project-based tracing
still works there.
- The plugin now needs LangSmith 0.14 or later. The floor is
`langsmith>=0.14.2`, since 0.14.0 and 0.14.1 were already excluded.
Every release from 0.14.2 on has `_resolve_traceable_addressing`,
`_addressing_tiers` and `RunTree.address`, so the plugin uses them
directly. That drops the `_setup_run` and `_get_project_name` fallback
for older releases, and the tests that faked them. CI doesn't run any
release before 0.14, so only those fakes checked that code.
- Replica addresses now survive a hop across Temporal. LangSmith still
leaves replicas out of `to_headers()`, so the plugin writes them itself,
but it wrote each address as a JSON dict. LangSmith only reads a replica
address back in its `lrn:` form (`lrn:agents/<id>/environments/<env>`,
the same form it writes for a run's own address), so it logged "Ignoring
an unusable address in a `baggage` header" and dropped it. The plugin
now writes that `lrn:` form itself, without importing anything from
`langsmith._internal`. Two existing tests read it back with the public
`RunTree.from_headers`, so if LangSmith ever changes the format, CI
tells us.
- `uv.lock` moves LangSmith from 0.14.4 to 0.14.12. Tests and the README
build addresses with `agent_address`.

`address=` came in with #115 and hasn't been released yet (the last
release, 0.1.1, came out on 10-28), so nobody depends on the string
form.

## Why?

The langsmith nightly has been red since #115 merged. Why? LangSmith
changed what an agent address is, and the plugin still speaks the old
format.

In LangSmith 0.14.4, the version we lock, an address is a string like
`"lrn:agents/support/environments/staging"`, and
`langsmith.address.parse` reads it. From 0.14.10 on, the string and
`parse` are gone. An address is now an `AgentAddress` dict that you
build with `langsmith.agent_address("support", "staging")`, and
LangSmith rejects strings. The nightly installs 0.14.12, so `address=`
fails with 7 pyright errors and 22 failing tests.

The other two nightly failures already have fixes: google_adk in #446
and openai_agents in #447.

## Checklist

1. Fixes #413.

2. How was this tested:

I ran `make lint` and `make test` with four sets of dependencies:

| Dependencies | LangSmith | Lint | Tests |
|---|---|---|---|
| This lock | 0.14.12 | pass | 295 passed |
| Latest allowed (nightly) | 0.14.16 | pass | 295 passed |
| Latest, plus newest LangSmith | 0.14.17 | pass | 295 passed |
| Lowest allowed LangSmith | 0.14.2 | not run | 173 passed |

On 0.14.2, I skipped the 3 test files that build addresses with
`agent_address`, since it only came in 0.14.9. Everything else passes
there.

0.14.17 comes out of the 2-week cooldown in 3 days, and it doesn't break
this again.

3. Any docs updates needed? Done here: the `python/langsmith` README
builds addresses with `agent_address`.

Let me know what you think!

---------

Co-authored-by: Brian Strauch <[email protected]>
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.

nightly: openai_agents failing (latest)

2 participants