CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.
Python agent-frameworkagent-harnessagent-runtimeagentic-aiai-agentsai-frameworkanthropicharnessharness-engineeringharness-frameworklanggraphlanggraph-alternativellmmcpopenaipi-agentpi-agent-corepythonpython-agent
test(tracing): cover fork_once span otel ImportError fallback
xf gongb7bc539a7218
diff --git a/tests/tracing/test_fork_once_span.py b/tests/tracing/test_fork_once_span.pyindex 8055c48..4cb0d33 100644--- a/tests/tracing/test_fork_once_span.py+++ b/tests/tracing/test_fork_once_span.py@@ -37,3 +37,37 @@ async def test_fork_once_emits_named_span(in_memory_exporter):attrs = dict(span.attributes)assert attrs["cubepi.fork.src_thread_id"] == "src"assert attrs["cubepi.fork.after_run_id"] == "R1"+++async def test_fork_once_span_falls_back_to_nullcontext_when_otel_missing(+ monkeypatch,+):+ """When the optional `tracing` extra isn't installed, the span helper+ must fall back to contextlib.nullcontext so fork_once still works."""+ import builtins++ real_import = builtins.__import__++ def _no_otel(name, *args, **kwargs):+ if name == "opentelemetry" or name.startswith("opentelemetry."):+ raise ImportError("simulated: opentelemetry not installed")+ return real_import(name, *args, **kwargs)++ monkeypatch.setattr(builtins, "__import__", _no_otel)++ cp = MemoryCheckpointer()+ a = Agent(+ model=_ok_faux().model("faux-model"),+ checkpointer=cp,+ thread_id="src",+ )+ await a.prompt("hello", run_id="R1")+ a2 = Agent(+ model=_ok_faux().model("faux-model"),+ checkpointer=cp,+ thread_id="src",+ )+ # Must not raise — the helper falls back to a no-op nullcontext.+ result = await a2.fork_once("src", "follow up?", after_run_id="R1")+ assert result is not None