Backtestsopenai-agents-pythonrun-20261024-184640#5290
After an approval, the resumed run records the approved tool span outside the agent span
The merged fix was judged better than our patch.
In this judgment, Patch B = our agent, Patch A = the merged fix.
Both patches fix the root cause the same way: they open the agent span before `resolve_interrupted_turn` on resume in both the blocking (`run.py`) and streamed (`run_loop.py`) paths, remove the later span-open block so it is not duplicated, and add `attach_generic_agent_error` to the streaming top-level exception handler so a resumed tool failure that bypasses the per-turn handler still marks the agent span with 'Error in agent run'. The independent tests confirm both resolve every scenario in the issue (parenting with task/turn spans on and off, streamed and not, stop_on_first_tool, and the error case). The differences are in completeness and testing. Patch A additionally threads the agent span into `resolve_interrupted_turn` and populates `span_data.tools`/`span_data.handoffs` from the resolved tools, so an agent span whose run ends on the approved tool (stop_on_first_tool or a raising tool) carries the same tool/handoff metadata it would have had without the interruption; Patch B leaves those lists empty in that case, a small but real inconsistency with the non-approval span the issue uses as its reference. Patch A's test is substantially more thorough: 16 parametrized cases covering continue, stop, error and handoff outcomes across streamed/non-streamed and task/turn spans on/off, and it asserts span parenting, tool/handoff metadata, both error messages, that every span ends, that span_start/span_end counts balance, and that no span is left current after the run — the last three guard against the main regression risk of opening the span earlier (a leaked or unbalanced span on a handoff or early return). Patch B's two tests cover success and error for both modes but do not cover stop_on_first_tool, handoff, or span-balance. Patch B's `start_agent_span` helper is a nice de-duplication and slightly cleaner craft, and its minimal placement right before `resolve_interrupted_turn` is tidy, but that does not outweigh A's broader verification and more complete agent span. A's extra parameter on `resolve_interrupted_turn` is a modest scope extension but directly serves the issue's expected behaviour and adds little risk.
Four judges ruled on this ticket in parallel, and the verdict comes from counting their votes. Each saw the issue and the two patches, labelled A and B in random order (two of them saw ours as A), with issue links and version numbers removed. Where tests could check the fix, they also saw the results of tests a separate agent wrote for the issue, run on both patches. None was told which patch was ours. The reasoning above is one judge's, shown verbatim.
Solve
9m 12s
Wall-clock time in the container
Full test suite
No new failures
2,624 passed · 1 skipped · 2,625 total
Contamination audit
Clean
No sign the agent saw the real fix
Patch size
148vs 170 merged
Changed lines, ours vs merged
The issue
View on GitHubPlease read this first
- Read the docs: yes.
- Searched for related issues: yes. #5045 dealt with trace reattachment on resume; nothing covers span parents.
Describe the bug
After state.approve(...), the resumed run executes the approved tool before it opens its agent span. The function span becomes a child of the task span, or of the trace root when task and turn spans are off. Only the paused span from the first run (docs/tracing.md:147) sits inside an agent span. If the approved tool has failure_error_function=None, as below, and raises, the resumed run ends without an agent span or Error in agent run.
resolve_interrupted_turn runs at src/agents/run.py:1115 while current_span is still None (:928). The agent span opens later, at :1492-1504. The streamed path has the same order, at src/agents/run_internal/run_loop.py:1323 and :1564-1576.
Debug information
- Agents SDK version: 0.22.3 from PyPI, the
v0.23.0tag, andmainata575a6e - Related library versions:
openai3.23.0,pydantic2.13.5 (PyPI install) - Python version: 3.12.3 (PyPI install), 3.14.7 (
v0.23.0andmain) - Operating system: Ubuntu 24.04
- Model and model provider: none,
agents.testing.ScriptedModel - Reproduces with the latest release: yes, PyPI 0.22.3 and the
v0.23.0tag (not on PyPI yet). - Consistent or intermittent: consistent, with
Runner.runandRunner.run_streamed.
Repro steps
import asyncio
import sys
from agents import Agent, Runner, add_trace_processor, function_tool
from agents.testing import ScriptedModel, assistant_message, function_call
from agents.tracing import TracingProcessor
STREAMED = "--streamed" in sys.argv
spans = {}
class Spans(TracingProcessor):
def on_trace_start(self, trace): pass
def on_trace_end(self, trace): pass
def on_span_start(self, span): pass
def on_span_end(self, span): spans[span.span_id] = span
def shutdown(self): pass
def force_flush(self): pass
add_trace_processor(Spans())
def show(title):
print(title)
for s in sorted(spans.values(), key=lambda s: s.started_at):
parent = spans.get(s.parent_id)
where = f"{parent.span_data.type}" if parent else "trace root"
error = f" error={s.error['message']!r}" if s.error else ""
print(f" {s.span_data.type:8} {s.span_data.export().get('name', ''):8} parent={where}{error}")
spans.clear()
@function_tool(name_override="refund", needs_approval=True, failure_error_function=None)
def approved_refund(order_id: str) -> str:
return f"refunded {order_id}"
@function_tool(name_override="refund", needs_approval=True, failure_error_function=None)
def approved_failing_refund(order_id: str) -> str:
raise RuntimeError("payments API down")
@function_tool(name_override="refund", failure_error_function=None)
def failing_refund(order_id: str) -> str:
raise RuntimeError("payments API down")
async def run(agent, input):
if STREAMED:
result = Runner.run_streamed(agent, input)
async for _ in result.stream_events():
pass
return result
return await Runner.run(agent, input)
def agent_with(tool):
model = ScriptedModel(
[[function_call("refund", {"order_id": "A1"}, call_id="c1")], [assistant_message("done")]]
)
return Agent(name="support", model=model, tools=[tool])
async def main():
try:
await run(agent_with(failing_refund), "refund A1")
except Exception as e:
show(f"no approval, tool raises ({type(e).__name__}):")
for tool in (approved_refund, approved_failing_refund):
agent = agent_with(tool)
first = await run(agent, "refund A1")
spans.clear() # the first run's paused refund span sits under its turn
state = first.to_state()
state.approve(first.interruptions[0])
try:
await run(agent, state)
outcome = "completed"
except Exception as e:
outcome = type(e).__name__
show(f"resumed after approval, tool {'raises' if tool is approved_failing_refund else 'succeeds'} ({outcome}):")
asyncio.run(main())
no approval, tool raises (UserError):
task task parent=trace root
agent support parent=task error='Error in agent run'
turn turn parent=agent
function refund parent=turn error='Error running tool'
resumed after approval, tool succeeds (completed):
task task parent=trace root
function refund parent=task
agent support parent=task
turn turn parent=agent
resumed after approval, tool raises (UserError):
task task parent=trace root
function refund parent=task error='Error running tool'
# main a575a6e; --streamed, the v0.23.0 tag and PyPI 0.22.3 print the same; not run: the default OpenAI exporter
Expected behavior
The approved tool span sits under the agent span, as it does without approval, and as tests/test_agent_tracing.py:288-292 asserts for function spans. An approved tool whose exception ends the run leaves Error in agent run on that agent span.
@seratch, is opening the agent span before resolve_interrupted_turn on resume the fix you would take?
The two patches
src/agents/run.pyindex 249ddfec..63ab89d5 100644@@ -126,6 +126,7 @@ from .run_internal.run_loop import ( run_input_guardrails, run_output_guardrails, run_single_turn,+ start_agent_span, start_streaming, validate_run_hooks, )@@ -160,7 +161,7 @@ from .sandbox.memory.rollouts import terminal_metadata_for_exception from .sandbox.runtime import SandboxRuntime from .tool import dispose_resolved_computers from .tool_guardrails import ToolInputGuardrailResult, ToolOutputGuardrailResult-from .tracing import Span, SpanError, agent_span, get_current_trace, task_span, turn_span+from .tracing import Span, SpanError, get_current_trace, task_span, turn_span from .tracing.config import include_task_and_turn_spans from .tracing.context import TraceCtxManager, create_trace_for_run from .tracing.span_data import AgentSpanData, TaskSpanData@@ -1112,6 +1113,10 @@ class AgentRunner: ), ) + # Approved tools run inside the resumed agent's span, as they+ # would have without the interruption.+ if current_span is None:+ current_span = start_agent_span(current_agent, execution_agent) turn_result = await resolve_interrupted_turn( bindings=current_bindings, original_input=original_input,@@ -1490,18 +1495,7 @@ class AgentRunner: run_state._generated_items = list(generated_items) run_state._session_items = list(session_items) if current_span is None:- if (output_schema := get_output_schema(execution_agent)) is not None:- output_type_name = output_schema.name()- else:- output_type_name = "str"-- current_span = agent_span(- name=current_agent.name,- handoffs=[],- tools=[],- output_type=output_type_name,- )- current_span.start(mark_as_current=True)+ current_span = start_agent_span(current_agent, execution_agent) current_turn += 1 if max_turns is not None and current_turn > max_turns:src/agents/run_internal/run_loop.pyindex bad24a83..0ca7c02d 100644@@ -278,6 +278,7 @@ __all__ = [ "get_model_tracing_impl", "validate_run_hooks", "cleanup_models_after_run",+ "start_agent_span", "finalize_max_turns_handler_output", "maybe_filter_model_input", "run_input_guardrails_with_queue",@@ -321,6 +322,23 @@ async def cleanup_models_after_run(tool_use_tracker: AgentToolUseTracker) -> Non log_model_action_warning(logger, "Failed to clean up model resources after run", error) +def start_agent_span(public_agent: Agent[Any], execution_agent: Agent[Any]) -> Span[AgentSpanData]:+ """Open the agent span and make it current so turn and tool spans nest under it."""+ if (output_schema := get_output_schema(execution_agent)) is not None:+ output_type_name = output_schema.name()+ else:+ output_type_name = "str"++ span = agent_span(+ name=public_agent.name,+ handoffs=[],+ tools=[],+ output_type=output_type_name,+ )+ span.start(mark_as_current=True)+ return span++ def _agent_diagnostic_extra(agent: Agent[Any]) -> dict[str, object]: return {"agent_name": agent.name} @@ -1320,6 +1338,10 @@ async def start_streaming( ), ) + # Approved tools run inside the resumed agent's span, as they would+ # have without the interruption.+ if current_span is None:+ current_span = start_agent_span(current_agent, execution_agent) turn_result = await resolve_interrupted_turn( bindings=current_bindings, original_input=run_state._original_input,@@ -1562,18 +1584,7 @@ async def start_streaming( run_state._session_items = list(streamed_result.new_items) if current_span is None:- if (output_schema := get_output_schema(execution_agent)) is not None:- output_type_name = output_schema.name()- else:- output_type_name = "str"-- current_span = agent_span(- name=current_agent.name,- handoffs=[],- tools=[],- output_type=output_type_name,- )- current_span.start(mark_as_current=True)+ current_span = start_agent_span(current_agent, execution_agent) current_turn += 1 streamed_result.current_turn = current_turn@@ -2011,6 +2022,13 @@ async def start_streaming( if _is_error_data_redacted(exc): _detach_data_redacted_error_traceback(exc) else:+ # Failures outside the per-turn handler, such as a resumed approved tool, still+ # end this agent run.+ attach_generic_agent_error(+ current_span,+ exc,+ trace_include_sensitive_data=run_config.trace_include_sensitive_data,+ ) _clear_data_redacted_error_traceback(exc) exc.run_data = RunErrorDetails( input=streamed_result.input,tests/test_agent_tracing.pyindex c0944399..e2191d8f 100644@@ -8,12 +8,14 @@ from inline_snapshot import snapshot from openai.types.responses.response_usage import InputTokensDetails from agents import Agent, RunConfig, Runner, RunState, custom_span, function_tool, trace+from agents.exceptions import UserError from agents.sandbox.runtime import SandboxRuntime from agents.testing import ScriptedModel from agents.usage import Usage from .test_responses import get_function_tool_call, get_text_message from .testing_processor import (+ SPAN_PROCESSOR_TESTING, assert_no_traces, fetch_events, fetch_normalized_spans,@@ -1153,3 +1155,87 @@ async def test_manual_streaming_disabling_works(): pass assert_no_traces()+++def _make_approved_refund_agent(*, raises: bool) -> Agent[None]:+ @function_tool(name_override="refund", needs_approval=True, failure_error_function=None)+ def refund(order_id: str) -> str:+ if raises:+ raise RuntimeError("payments API down")+ return f"refunded {order_id}"++ model = ScriptedModel(+ [+ [get_function_tool_call("refund", '{"order_id": "A1"}', call_id="call-1")],+ [get_text_message("done")],+ ]+ )+ return Agent(name="support", model=model, tools=[refund])+++async def _run_to_completion(+ agent: Agent[None],+ input: str | RunState[None],+ *,+ streamed: bool,+ run_config: RunConfig | None = None,+):+ if streamed:+ result = Runner.run_streamed(agent, input, run_config=run_config)+ async for _ in result.stream_events():+ pass+ return result+ return await Runner.run(agent, input, run_config=run_config)+++@pytest.mark.asyncio+@pytest.mark.parametrize("streamed", [False, True])+@pytest.mark.parametrize("include_task_and_turn_spans", [True, False])+async def test_resumed_approved_tool_span_is_inside_agent_span(+ streamed: bool, include_task_and_turn_spans: bool+) -> None:+ run_config = RunConfig(tracing={"include_task_and_turn_spans": include_task_and_turn_spans})+ agent = _make_approved_refund_agent(raises=False)++ first = await _run_to_completion(agent, "refund A1", streamed=streamed, run_config=run_config)+ assert first.interruptions+ state = first.to_state()+ state.approve(first.interruptions[0])+ SPAN_PROCESSOR_TESTING.clear()++ resumed = await _run_to_completion(agent, state, streamed=streamed, run_config=run_config)++ assert resumed.final_output == "done"+ spans = fetch_ordered_spans()+ agent_spans = [span for span in spans if span.span_data.type == "agent"]+ function_spans = [span for span in spans if span.span_data.type == "function"]+ assert len(agent_spans) == 1+ assert len(function_spans) == 1+ assert function_spans[0].parent_id == agent_spans[0].span_id+ assert spans.index(agent_spans[0]) < spans.index(function_spans[0])+++@pytest.mark.asyncio+@pytest.mark.parametrize("streamed", [False, True])+async def test_resumed_approved_tool_failure_marks_agent_span(streamed: bool) -> None:+ agent = _make_approved_refund_agent(raises=True)++ first = await _run_to_completion(agent, "refund A1", streamed=streamed)+ assert first.interruptions+ state = first.to_state()+ state.approve(first.interruptions[0])+ SPAN_PROCESSOR_TESTING.clear()++ with pytest.raises(UserError):+ await _run_to_completion(agent, state, streamed=streamed)++ spans = fetch_ordered_spans()+ agent_spans = [span for span in spans if span.span_data.type == "agent"]+ function_spans = [span for span in spans if span.span_data.type == "function"]+ assert len(agent_spans) == 1+ assert len(function_spans) == 1+ assert function_spans[0].parent_id == agent_spans[0].span_id+ assert function_spans[0].error is not None+ assert function_spans[0].error["message"] == "Error running tool"+ assert agent_spans[0].error is not None+ assert agent_spans[0].error["message"] == "Error in agent run"
src/agents/run.pyindex 249ddfec6..17d90bb2d 100644@@ -1082,6 +1082,22 @@ class AgentRunner: wrapper=context_wrapper, ) session_input_items_for_persistence = []+ # Resumed tool work belongs to the agent even when it finishes or fails+ # before another model turn starts. Keep turn accounting below.+ if current_span is None:+ if (output_schema := get_output_schema(execution_agent)) is not None:+ output_type_name = output_schema.name()+ else:+ output_type_name = "str"++ current_span = agent_span(+ name=current_agent.name,+ handoffs=[],+ tools=[],+ output_type=output_type_name,+ )+ current_span.start(mark_as_current=True)+ if run_state is not None and run_state._current_step is not None: if isinstance(run_state._current_step, NextStepInterruption): logger.debug("Continuing from interruption")@@ -1113,6 +1129,7 @@ class AgentRunner: ) turn_result = await resolve_interrupted_turn(+ agent_span=current_span, bindings=current_bindings, original_input=original_input, original_pre_step_items=generated_items,@@ -1489,20 +1506,6 @@ class AgentRunner: if not run_state._pending_input: run_state._generated_items = list(generated_items) run_state._session_items = list(session_items)- if current_span is None:- if (output_schema := get_output_schema(execution_agent)) is not None:- output_type_name = output_schema.name()- else:- output_type_name = "str"-- current_span = agent_span(- name=current_agent.name,- handoffs=[],- tools=[],- output_type=output_type_name,- )- current_span.start(mark_as_current=True)- current_turn += 1 if max_turns is not None and current_turn > max_turns: _error_tracing.attach_error_to_span(src/agents/run_internal/run_loop.pyindex bad24a835..688a3a900 100644@@ -1287,6 +1287,22 @@ async def start_streaming( run_state._nested_history_owned_session_item_refs = list(retained_owned_refs) sandbox_runtime.apply_result_metadata(streamed_result) + # Resumed tool work belongs to the agent even when it finishes or fails+ # before another model turn starts. Keep turn accounting below.+ if current_span is None:+ if (output_schema := get_output_schema(execution_agent)) is not None:+ output_type_name = output_schema.name()+ else:+ output_type_name = "str"++ current_span = agent_span(+ name=current_agent.name,+ handoffs=[],+ tools=[],+ output_type=output_type_name,+ )+ current_span.start(mark_as_current=True)+ if is_resumed_state and run_state is not None and run_state._current_step is not None: if isinstance(run_state._current_step, NextStepInterruption): if not run_state._model_responses:@@ -1321,6 +1337,7 @@ async def start_streaming( ) turn_result = await resolve_interrupted_turn(+ agent_span=current_span, bindings=current_bindings, original_input=run_state._original_input, original_pre_step_items=run_state._generated_items,@@ -1561,20 +1578,6 @@ async def start_streaming( run_state._generated_items = list(streamed_result._model_input_items) run_state._session_items = list(streamed_result.new_items) - if current_span is None:- if (output_schema := get_output_schema(execution_agent)) is not None:- output_type_name = output_schema.name()- else:- output_type_name = "str"-- current_span = agent_span(- name=current_agent.name,- handoffs=[],- tools=[],- output_type=output_type_name,- )- current_span.start(mark_as_current=True)- current_turn += 1 streamed_result.current_turn = current_turn streamed_result._current_turn_persisted_item_count = 0@@ -2011,6 +2014,11 @@ async def start_streaming( if _is_error_data_redacted(exc): _detach_data_redacted_error_traceback(exc) else:+ attach_generic_agent_error(+ current_span,+ exc,+ trace_include_sensitive_data=run_config.trace_include_sensitive_data,+ ) _clear_data_redacted_error_traceback(exc) exc.run_data = RunErrorDetails( input=streamed_result.input,src/agents/run_internal/turn_resolution.pyindex 9906b6715..e143de5c2 100644@@ -43,6 +43,7 @@ from .._tool_identity import ( get_tool_call_namespace, get_tool_call_qualified_name, get_tool_call_trace_name,+ get_tool_trace_name_for_tool, resolve_tool_name_collisions, restore_tool_call_routing_identity, should_allow_bare_name_approval_alias,@@ -115,7 +116,7 @@ from ..tool import ( get_function_tool_origin, ) from ..tool_guardrails import ToolInputGuardrailResult, ToolOutputGuardrailResult-from ..tracing import SpanError, handoff_span+from ..tracing import AgentSpanData, Span, SpanError, handoff_span from ..util import _coro, _error_tracing from ..util._approvals import evaluate_needs_approval_setting from ..util._asyncio_tasks import gather_with_cancel@@ -1156,6 +1157,7 @@ async def resolve_interrupted_turn( run_state: RunState | None = None, error_handlers: RunErrorHandlers[TContext] | None = None, nest_handoff_history_fn: Callable[..., HandoffInputData] | None = None,+ agent_span: Span[AgentSpanData] | None = None, ) -> SingleStepResult: """Continue a turn that was previously interrupted waiting for tool approval.""" public_agent = bindings.public_agent@@ -2011,6 +2013,13 @@ async def resolve_interrupted_turn( available_handoffs, collision_policy=run_config.tool_name_collision_policy, )+ if agent_span is not None:+ agent_span.span_data.handoffs = [handoff.agent_name for handoff in resolved_handoffs]+ agent_span.span_data.tools = [+ tool_name+ for tool in resolved_tools+ if (tool_name := get_tool_trace_name_for_tool(tool)) is not None+ ] resolved_function_tools = [tool for tool in resolved_tools if isinstance(tool, FunctionTool)] local_function_tool_ids = { id(tool) for tool in execution_agent.tools if isinstance(tool, FunctionTool)tests/test_agent_tracing.pyindex c09443994..2feae7e00 100644@@ -8,11 +8,13 @@ from inline_snapshot import snapshot from openai.types.responses.response_usage import InputTokensDetails from agents import Agent, RunConfig, Runner, RunState, custom_span, function_tool, trace+from agents.exceptions import UserError from agents.sandbox.runtime import SandboxRuntime from agents.testing import ScriptedModel+from agents.tracing import get_current_span from agents.usage import Usage -from .test_responses import get_function_tool_call, get_text_message+from .test_responses import get_function_tool_call, get_handoff_tool_call, get_text_message from .testing_processor import ( assert_no_traces, fetch_events,@@ -396,6 +398,94 @@ async def test_multiple_runs_are_multiple_traces(): ) +@pytest.mark.asyncio+@pytest.mark.parametrize("streamed", [False, True])+@pytest.mark.parametrize("include_task_and_turn_spans", [False, True])+@pytest.mark.parametrize("outcome", ["continue", "stop", "error", "handoff"])+async def test_approved_tool_executes_inside_resumed_agent_span(+ streamed: bool, include_task_and_turn_spans: bool, outcome: str+) -> None:+ calls = 0++ @function_tool(needs_approval=True, failure_error_function=None)+ def approved_tool() -> str:+ nonlocal calls+ calls += 1+ if outcome == "error":+ raise RuntimeError("synthetic tool failure")+ return "tool result"++ target = Agent(name="target", model=ScriptedModel(steps=[[get_text_message("done")]]))+ first_response = [get_function_tool_call("approved_tool", "{}")]+ if outcome == "handoff":+ first_response.append(get_handoff_tool_call(target))+ agent = Agent(+ name="approval agent",+ tools=[approved_tool],+ handoffs=[target] if outcome == "handoff" else [],+ model=ScriptedModel(+ steps=[+ first_response,+ [get_text_message("done")],+ ]+ ),+ tool_use_behavior="stop_on_first_tool" if outcome == "stop" else "run_llm_again",+ )+ config = RunConfig(tracing={"include_task_and_turn_spans": include_task_and_turn_spans})++ async def run(input: str | RunState[None]):+ # A direct tool-result resume must not consume another model turn.+ max_turns = 1 if outcome == "stop" else 2+ if streamed:+ result = Runner.run_streamed(agent, input, run_config=config, max_turns=max_turns)+ async for _ in result.stream_events():+ pass+ return result+ return await Runner.run(agent, input, run_config=config, max_turns=max_turns)++ first = await run("run the tool")+ assert calls == 0+ assert len(first.interruptions) == 1+ state = first.to_state()+ state.approve(first.interruptions[0])+ initial_span_ids = {span.span_id for span in fetch_ordered_spans()}++ if outcome == "error":+ with pytest.raises(UserError, match="synthetic tool failure"):+ await run(state)+ else:+ result = await run(state)+ assert result.final_output == ("tool result" if outcome == "stop" else "done")++ assert calls == 1+ spans = [span for span in fetch_ordered_spans() if span.span_id not in initial_span_ids]+ agent_spans = [span for span in spans if span.span_data.type == "agent"]+ function_spans = [span for span in spans if span.span_data.type == "function"]+ assert len(agent_spans) == (2 if outcome == "handoff" else 1)+ assert len(function_spans) == 1+ agent_span = agent_spans[0]+ assert function_spans[0].parent_id == agent_span.span_id+ assert agent_span.span_data.name == "approval agent"+ assert agent_span.span_data.tools == ["approved_tool"]+ assert agent_span.span_data.handoffs == (["target"] if outcome == "handoff" else [])+ if outcome == "handoff":+ assert agent_spans[1].span_data.name == "target"+ assert agent_spans[1].parent_id == agent_span.parent_id+ handoff_spans = [span for span in spans if span.span_data.type == "handoff"]+ assert len(handoff_spans) == 1+ assert handoff_spans[0].parent_id == agent_span.span_id+ if outcome == "error":+ assert agent_span.error is not None+ assert agent_span.error["message"] == "Error in agent run"+ assert function_spans[0].error is not None+ assert function_spans[0].error["message"] == "Error running tool"+ else:+ assert agent_span.error is None+ assert all(span.ended_at is not None for span in spans)+ assert fetch_events().count("span_start") == fetch_events().count("span_end")+ assert get_current_span() is None++ @pytest.mark.asyncio async def test_resumed_run_reuses_original_trace_without_duplicate_trace_start(): model = ScriptedModel()