Repository navigation
fix(tests): walk through the llm.<model> span in the auto-title trace assertion - #4911
simonrosenberg wants to merge 1 commit into
Conversation
… assertion #4836 gave Telemetry.on_request its own `llm.<model>` span, which stays current while the call runs so the authoritative cost can be attached before lmnr ends `litellm.completion`. That span now sits between the operation span and the LLM span, so `litellm.completion`'s immediate parent is `llm.gpt-4o` rather than `conversation.generate_title`. tests/sdk/conversation/test_utility_llm_span_metadata.py was updated for that in the same PR; this agent-server counterpart was missed and has had main red since. Same treatment: `parent` walks through the wrapper to the operation the call belongs to, `immediate_parent` keeps the wrapper itself under assertion. The tracing was correct throughout — the title span is still in the conversation trace, under `conversation.generate_title`. Only the assertion was stale. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
|
🤖 OpenHands is reviewing this PR. Head commit: This comment was posted by an AI agent (OpenHands). |
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was created by an AI agent (OpenHands) on behalf of the repository maintainers.
🟢 Good taste
No material code findings. This test-only change matches the established sibling-test pattern, preserves the immediate-parent assertion for the synthetic llm.<model> span, and correctly walks to conversation.generate_title for operation attribution. The focused test passes locally, and the exact-head agent-server-tests check is green.
The required Validate PR description check is currently failing with these validator errors:
The first visible line of the PR description must be HUMAN:.Add a short human-written note between HUMAN: and AGENT:.Keep the AGENT: marker from the PR template.Link an issue in the ## Issue Number section (e.g. Fixes #123). Newly opened issues must carry the ready-for-dev label.
Because the HUMAN: field is human-only, a human contributor needs to update the PR description before merge.
[RISK ASSESSMENT]
- [Overall PR]
⚠️ Risk Assessment: 🟢 LOW
The change is isolated to a tracing assertion in one test, introduces no production behavior, API, dependency, persistence, or security changes, and has passing targeted and CI validation.
VERDICT:
✅ Worth merging once the required PR-description metadata check is fixed by a human.
KEY INSIGHT:
The updated test now verifies both levels of the intended span hierarchy instead of treating the synthetic cost span as a tracing regression.
|
Closing as redundant — this was fixed independently in #4908 (Release v1.46.0), which landed on main as Their fix asserts the two-level chain explicitly: sdk_llm_spans = [span for span in probe["spans"] if span["name"] == "llm.gpt-4o"]
assert sdk_llm["parent"] == "conversation.generate_title"
assert title_llm["parent"] == "llm.gpt-4o"Verified main is green: One difference worth noting for whoever touches this next, not worth a PR on its own: their version hard-codes the span name #4912 stays open and is unaffected — the path-filter gap that let this reach main with every required check green is still there. That is the part with lasting value here. |
HUMAN:
Verified the span tree myself and confirmed the tracing is correct — it's the assertion that went stale, not the instrumentation.
AGENT:
Why
mainis red.agent-server-testsfails on every PR that touches an agent-server path:#4836 gave
Telemetry.on_requestits ownllm.<model>span, which stays current while the call runs so the authoritative cost can be attached before lmnr ends itslitellm.completionspan. That span now sits between the operation span and the LLM span:The tracing is correct. The title LLM span is still in the conversation trace and still under
conversation.generate_title; only the direct-parent assertion was stale.tests/sdk/conversation/test_utility_llm_span_metadata.pywas updated for exactly this in the same PR — it grew anoperation_parent()helper that skips thellm.wrapper, plus a separateimmediate_parent. The agent-server counterpart was missed.How it reached main past a required check
Worth recording, because it is not obvious and it is why #4836's author never saw this test fail.
agent-server-testsis path-gated — every step isif: steps.changed.outputs.any_changed == 'true'overopenhands-agent-server/**,tests/agent_server/**,pyproject.toml,uv.lock,.github/workflows/tests.yml. When nothing matches, the job executes nothing and still reportssuccess.fc9646ad8(#4836)56b016e7f(#4839)#4836's diff is
openhands-sdk/**+tests/sdk/**only, so the job was green having run nothing. #4839 touched agent-server paths, opening the gate, and so became the first commit to actually run this test since #4836 landed. #4836 is the cause; #4839 is only the detector.The filter gap itself is broader than this PR fixes and is tracked separately in #4912.
Summary
parentnow walks through the syntheticllm.<model>wrapper to the operation the call belongs to, matching theoperation_parent()helper the sibling SDK test already uses rather than inventing a second convention.immediate_parentis added and asserted, so the test still fails if the LLM span detaches or the wrapper disappears silently.trace_idandtitle_generationoperation-attribute assertions are unchanged. No production code changes.Issue Number
Related to #4912 — this PR fixes the test breakage reported there; the CI path-filter gap in that issue is a separate change.
How to Test
Fails on
main, passes on this branch. Verified it is not a local artifact by reproducing on a clean detached worktree atfc9646ad8with none of this branch's changes present — deterministic, 3/3 runs.Full agent-server suite on this branch:
The span tree the probe actually emits, which is what the new assertions encode:
Type
Notes
Test-only change; no production code touched. Unblocks every PR whose diff opens the
agent-server-testsgate, including #4864.🤖 Generated with Claude Code