Skip to content

Conversation

@constantinius
Copy link
Contributor

@constantinius constantinius requested a review from a team as a code owner January 14, 2026 09:36
@linear
Copy link

linear bot commented Jan 14, 2026

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Span Streaming

  • feat(span-streaming): Add spans to telemetry pipeline, add span name and attributes (3) by sentrivana in #5399
  • feat(span-streaming): Add span batcher (2) by sentrivana in #5398
  • feat(span-streaming): Add experimental trace_lifecycle switch (1) by sentrivana in #5397

Other

  • feat(integration): add gen_ai.conversation.id if available by constantinius in #5307

Bug Fixes 🐛

Google Genai

  • fix(google-genai): Token reporting by alexander-alderman-webb in #5404
  • fix(google-genai): deactivate google genai when langchain is used by shellmayr in #5389

Span Streaming

  • fix(span-streaming): Always preserialize attributes by sentrivana in #5407
  • fix(span-streaming): Warn about thread usage if any batcher is active by sentrivana in #5408

Other

  • fix(anthropic): Token reporting by alexander-alderman-webb in #5403
  • fix(arq): handle settings_cls passed as keyword argument by nc9 in #5393
  • fix(dramatiq): cleanup isolated scope and transaction when message is skipped by frankie567 in #5346
  • fix(openai): Token reporting by alexander-alderman-webb in #5406
  • fix(openai-agents): Inject propagation headers for HostedMCPTool when streaming by alexander-alderman-webb in #5405
  • fix: Adapt to new packaging in toxgen by sentrivana in #5382

Internal Changes 🔧

Fastmcp

  • test(fastmcp): Wrap prompt in Message by alexander-alderman-webb in #5411
  • test(fastmcp): Remove test_fastmcp_without_request_context() by alexander-alderman-webb in #5412
  • test(fastmcp): Use AsyncClient for SSE by alexander-alderman-webb in #5400
  • test(fastmcp): Use TestClient for Streamable HTTP by alexander-alderman-webb in #5384
  • test(fastmcp): Simulate stdio transport with memory streams by alexander-alderman-webb in #5333

Mcp

  • test(mcp): Use AsyncClient for SSE by alexander-alderman-webb in #5396
  • test(mcp): Use TestClient for Streamable HTTP by alexander-alderman-webb in #5383
  • test(mcp): Remove unused stdio helpers by alexander-alderman-webb in #5409
  • test(mcp): Simulate stdio transport with memory streams by alexander-alderman-webb in #5329

Other

  • ci: 🤖 Update test matrix with new releases (02/02) by github-actions in #5413
  • ci: Update tox and pin packaging version for tox by alexander-alderman-webb in #5381
  • ci: migration to the new codecov action by MathurAditya724 in #5392

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

Codecov Results 📊

25 passed | ⏭️ 2 skipped | Total: 27 | Pass Rate: 92.59% | Execution Time: 4.35s

All tests are passing successfully.

❌ Patch coverage is 6.90%. Project has 13839 uncovered lines.

Files with missing lines (180)
File Patch % Lines
langchain.py 3.28% ⚠️ 590 Missing
utils.py 52.08% ⚠️ 438 Missing and 76 partials
openai.py 5.57% ⚠️ 492 Missing
utils.py 0.00% ⚠️ 479 Missing
__init__.py 5.08% ⚠️ 374 Missing
tracing_utils.py 48.48% ⚠️ 305 Missing and 46 partials
scope.py 68.82% ⚠️ 256 Missing and 75 partials
transport.py 23.04% ⚠️ 304 Missing and 2 partials
client.py 58.76% ⚠️ 207 Missing and 65 partials
mcp.py 4.85% ⚠️ 255 Missing
anthropic.py 9.16% ⚠️ 248 Missing
transaction_profiler.py 35.52% ⚠️ 216 Missing and 10 partials
__init__.py 3.93% ⚠️ 220 Missing
utils.py 16.34% ⚠️ 215 Missing
langgraph.py 5.29% ⚠️ 215 Missing
span_processor.py 0.00% ⚠️ 205 Missing
__init__.py 5.14% ⚠️ 203 Missing
tracing.py 69.26% ⚠️ 146 Missing and 48 partials
starlette.py 52.25% ⚠️ 170 Missing and 24 partials
continuous_profiler.py 43.45% ⚠️ 177 Missing and 17 partials
aws_lambda.py 16.50% ⚠️ 167 Missing
spark_driver.py 0.00% ⚠️ 166 Missing
huggingface_hub.py 8.89% ⚠️ 164 Missing
sanic.py 9.60% ⚠️ 160 Missing
cloud_resource_context.py 0.00% ⚠️ 145 Missing
ai_client.py 0.00% ⚠️ 145 Missing
rust_tracing.py 0.00% ⚠️ 143 Missing
litellm.py 0.00% ⚠️ 138 Missing
litestar.py 9.59% ⚠️ 132 Missing
starlite.py 8.33% ⚠️ 132 Missing
envelope.py 40.82% ⚠️ 116 Missing and 11 partials
aiohttp.py 30.72% ⚠️ 115 Missing and 2 partials
falcon.py 8.94% ⚠️ 112 Missing
spotlight.py 28.47% ⚠️ 103 Missing and 8 partials
cohere.py 12.70% ⚠️ 110 Missing
dramatiq.py 0.00% ⚠️ 110 Missing
agent_run.py 0.00% ⚠️ 110 Missing
arq.py 9.92% ⚠️ 109 Missing
asgi.py 0.00% ⚠️ 109 Missing
hub.py 45.60% ⚠️ 105 Missing and 3 partials
pymongo.py 10.17% ⚠️ 106 Missing
beat.py 8.62% ⚠️ 106 Missing
caching.py 0.00% ⚠️ 106 Missing
utils.py 0.00% ⚠️ 103 Missing
logging.py 35.95% ⚠️ 98 Missing and 3 partials
templates.py 0.00% ⚠️ 100 Missing
asyncpg.py 11.61% ⚠️ 99 Missing
quart.py 16.10% ⚠️ 99 Missing
models.py 4.81% ⚠️ 99 Missing
gcp.py 0.00% ⚠️ 98 Missing
otlp.py 0.00% ⚠️ 97 Missing
utils.py 13.39% ⚠️ 97 Missing
pyramid.py 13.76% ⚠️ 94 Missing
tornado.py 14.55% ⚠️ 94 Missing
__init__.py 0.00% ⚠️ 93 Missing
bottle.py 11.65% ⚠️ 91 Missing
middleware.py 0.00% ⚠️ 90 Missing
agent_run.py 0.00% ⚠️ 90 Missing
stdlib.py 35.82% ⚠️ 86 Missing and 1 partials
runner.py 0.00% ⚠️ 87 Missing
beam.py 0.00% ⚠️ 84 Missing
loguru.py 11.58% ⚠️ 84 Missing
ray.py 0.00% ⚠️ 84 Missing
asyncio.py 0.00% ⚠️ 80 Missing
invoke_agent.py 0.00% ⚠️ 79 Missing
clickhouse_driver.py 17.58% ⚠️ 75 Missing
pure_eval.py 0.00% ⚠️ 73 Missing
worker.py 22.58% ⚠️ 72 Missing
sqlalchemy.py 10.26% ⚠️ 70 Missing
monitoring.py 17.07% ⚠️ 68 Missing
transactions.py 0.00% ⚠️ 67 Missing
_queue.py 26.67% ⚠️ 66 Missing
rq.py 15.38% ⚠️ 66 Missing
huey.py 17.72% ⚠️ 65 Missing
_wsgi_common.py 55.12% ⚠️ 57 Missing and 6 partials
utils.py 16.00% ⚠️ 63 Missing
streaming.py 0.00% ⚠️ 62 Missing
sessions.py 60.15% ⚠️ 53 Missing and 8 partials
api.py 60.40% ⚠️ 59 Missing
asgi.py 68.57% ⚠️ 44 Missing and 15 partials
chalice.py 16.18% ⚠️ 57 Missing
propagator.py 0.00% ⚠️ 57 Missing
server.py 0.00% ⚠️ 56 Missing
spark_worker.py 0.00% ⚠️ 56 Missing
graph_nodes.py 0.00% ⚠️ 52 Missing
gnu_backtrace.py 0.00% ⚠️ 51 Missing
_async_common.py 0.00% ⚠️ 51 Missing
socket.py 0.00% ⚠️ 50 Missing
views.py 0.00% ⚠️ 50 Missing
tools.py 0.00% ⚠️ 49 Missing
caches.py 16.95% ⚠️ 49 Missing
_batcher.py 41.25% ⚠️ 47 Missing
boto3.py 37.84% ⚠️ 46 Missing
invoke_agent.py 0.00% ⚠️ 46 Missing
signals_handlers.py 0.00% ⚠️ 44 Missing
utils.py 22.22% ⚠️ 42 Missing and 1 partials
threading.py 63.16% ⚠️ 35 Missing and 5 partials
client.py 0.00% ⚠️ 40 Missing
_sync_common.py 22.00% ⚠️ 39 Missing
executing.py 0.00% ⚠️ 38 Missing
flask.py 72.66% ⚠️ 35 Missing and 3 partials
client.py 0.00% ⚠️ 38 Missing
_span_batcher.py 35.71% ⚠️ 36 Missing
serverless.py 0.00% ⚠️ 36 Missing
server.py 0.00% ⚠️ 35 Missing
session.py 78.89% ⚠️ 19 Missing and 13 partials
strawberry.py 89.95% ⚠️ 20 Missing and 12 partials
sys_exit.py 0.00% ⚠️ 32 Missing
serializer.py 87.10% ⚠️ 24 Missing and 7 partials
launchdarkly.py 0.00% ⚠️ 31 Missing
trytond.py 0.00% ⚠️ 30 Missing
tools.py 0.00% ⚠️ 30 Missing
integration.py 0.00% ⚠️ 30 Missing
error_tracing.py 0.00% ⚠️ 29 Missing
fastapi.py 76.83% ⚠️ 19 Missing and 9 partials
wsgi.py 82.81% ⚠️ 22 Missing and 6 partials
httpx.py 65.75% ⚠️ 25 Missing and 2 partials
ai_client.py 13.33% ⚠️ 26 Missing
execute_tool.py 0.00% ⚠️ 26 Missing
_openai_completions_api.py 19.35% ⚠️ 25 Missing
redis_cluster.py 26.47% ⚠️ 25 Missing
typer.py 0.00% ⚠️ 24 Missing
tasks.py 0.00% ⚠️ 24 Missing
_compat.py 41.03% ⚠️ 23 Missing
monitor.py 67.21% ⚠️ 20 Missing and 3 partials
statsig.py 0.00% ⚠️ 23 Missing
queries.py 25.81% ⚠️ 23 Missing
logger.py 43.59% ⚠️ 22 Missing
decorator.py 37.14% ⚠️ 22 Missing
__init__.py 84.78% ⚠️ 14 Missing and 8 partials
_log_batcher.py 0.00% ⚠️ 21 Missing
attachments.py 27.59% ⚠️ 21 Missing
unraisablehook.py 0.00% ⚠️ 21 Missing
__init__.py 8.70% ⚠️ 21 Missing
openfeature.py 0.00% ⚠️ 20 Missing
execute_tool.py 0.00% ⚠️ 20 Missing
unleash.py 0.00% ⚠️ 19 Missing
_lru_cache.py 43.33% ⚠️ 17 Missing and 1 partials
model_request.py 0.00% ⚠️ 18 Missing
traces.py 41.38% ⚠️ 17 Missing
_werkzeug.py 55.56% ⚠️ 12 Missing and 4 partials
gql.py 84.81% ⚠️ 12 Missing and 4 partials
utils.py 0.00% ⚠️ 16 Missing
atexit.py 56.25% ⚠️ 14 Missing and 1 partials
excepthook.py 56.25% ⚠️ 14 Missing and 1 partials
redis.py 25.00% ⚠️ 15 Missing
feature_flags.py 56.25% ⚠️ 14 Missing
scrubber.py 88.41% ⚠️ 8 Missing and 6 partials
_init_implementation.py 45.83% ⚠️ 13 Missing
__init__.py 27.78% ⚠️ 13 Missing
types.py 0.00% ⚠️ 12 Missing
dedupe.py 80.00% ⚠️ 8 Missing and 3 partials
redis_py_cluster_legacy.py 26.67% ⚠️ 11 Missing
api.py 37.50% ⚠️ 10 Missing
utils.py 41.18% ⚠️ 10 Missing
handoff.py 0.00% ⚠️ 10 Missing
metrics.py 47.06% ⚠️ 9 Missing
_asgi_common.py 92.59% ⚠️ 4 Missing and 5 partials
__init__.py 72.41% ⚠️ 8 Missing and 1 partials
_types.py 73.33% ⚠️ 8 Missing
graphene.py 93.59% ⚠️ 5 Missing and 3 partials
_metrics_batcher.py 65.00% ⚠️ 7 Missing
consts.py 0.00% ⚠️ 7 Missing
rb.py 30.00% ⚠️ 7 Missing
_openai_responses_api.py 33.33% ⚠️ 6 Missing
ariadne.py 96.39% ⚠️ 3 Missing and 3 partials
debug.py 91.30% ⚠️ 2 Missing and 2 partials
consts.py 0.00% ⚠️ 4 Missing
__init__.py 20.00% ⚠️ 4 Missing
__init__.py 0.00% ⚠️ 4 Missing
__init__.py 0.00% ⚠️ 3 Missing
__init__.py 40.00% ⚠️ 3 Missing
__init__.py 0.00% ⚠️ 3 Missing
__init__.py 0.00% ⚠️ 3 Missing
__init__.py 0.00% ⚠️ 3 Missing
consts.py 99.43% ⚠️ 2 Missing
agent_workflow.py 71.43% ⚠️ 2 Missing
argv.py 100.00% ⚠️ 1 partials
consts.py 0.00% ⚠️ 1 Missing
consts.py 0.00% ⚠️ 1 Missing

Generated by Codecov Action

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

# Add conversation ID from agent
conv_id = getattr(agent, "_sentry_conversation_id", None)
if conv_id:
span.set_data(SPANDATA.GEN_AI_CONVERSATION_ID, conv_id)
Copy link

Choose a reason for hiding this comment

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

Duplicated pattern for setting conversation ID on spans

Low Severity

The same 3-line pattern for extracting and setting _sentry_conversation_id from an agent onto a span is repeated 4 times across execute_tool.py, handoff.py, invoke_agent.py, and ai_client.py. This pattern should be extracted to a utility function in utils.py (e.g., _set_conversation_id(span, agent)), following the existing pattern of _set_agent_data, _set_usage_data, etc.

Fix in Cursor Fix in Web

Comment on lines 18 to +25
origin=SPAN_ORIGIN,
) as span:
span.set_data(SPANDATA.GEN_AI_OPERATION_NAME, "handoff")

# Add conversation ID from agent
conv_id = getattr(from_agent, "_sentry_conversation_id", None)
if conv_id:
span.set_data(SPANDATA.GEN_AI_CONVERSATION_ID, conv_id)
Copy link

Choose a reason for hiding this comment

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

Bug: The _sentry_conversation_id is not propagated to the secondary agent during a handoff, causing subsequent spans from that agent to lack the conversation ID.
Severity: MEDIUM

Suggested Fix

Modify the handoff patching logic to access the secondary agent object, not just its name. Once the secondary agent instance is available, copy the _sentry_conversation_id attribute from the primary agent to the secondary agent before the handoff is executed. This will ensure that spans created by the secondary agent are correctly associated with the ongoing conversation.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: sentry_sdk/integrations/openai_agents/spans/handoff.py#L18-L25

Potential issue: During an agent handoff, the `_sentry_conversation_id` is correctly
applied to the handoff span itself but is not propagated to the secondary agent instance
that takes over the workflow. When this secondary agent subsequently runs, it does not
have the `_sentry_conversation_id` attribute set. As a result, any spans it generates
will be missing the conversation ID, because the logic relies on `getattr(agent,
"_sentry_conversation_id", None)`, which will return `None`. This breaks end-to-end
conversation tracking in multi-agent scenarios.

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.

3 participants