Skip to content

Commit b583b0a

Browse files
Apply review fixes to tier-2a harness
Address review feedback on the tier-2a fixture wiring: - _run_langfuse_trace_case wraps invoke/drain in try/finally so the observer is always shut down, even if the graph raises. - _run_invocation_id_case now holds the LangfuseObserver reference and shuts it down in finally, matching the other Langfuse runners. - _assert_langfuse_observation_tree enables the value-matcher only when both bindings and params are provided (and, not or), so a partial call degrades to exact match instead of half-enabling the matcher.
1 parent 9a4e2b2 commit b583b0a

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

tests/conformance/test_observability.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,9 +2753,11 @@ async def _run_langfuse_trace_case(case: Mapping[str, Any]) -> None:
27532753
compiled = built.builder.compile()
27542754
compiled.attach_observer(observer)
27552755
initial_state = built.initial_state(case.get("initial_state", {}))
2756-
await compiled.invoke(initial_state)
2757-
await compiled.drain()
2758-
observer.shutdown()
2756+
try:
2757+
await compiled.invoke(initial_state)
2758+
await compiled.drain()
2759+
finally:
2760+
observer.shutdown()
27592761

27602762
assert len(client.traces) == 1, f"expected 1 Langfuse trace; got {len(client.traces)}"
27612763
trace = next(iter(client.traces.values()))
@@ -2789,13 +2791,15 @@ async def _run_invocation_id_case(case: Mapping[str, Any]) -> None:
27892791

27902792
graph, state_cls, provider = _build_simple_llm_graph(case, populate_caller_metadata=False)
27912793
client = InMemoryLangfuseClient()
2792-
graph.attach_observer(LangfuseObserver(client=client))
2794+
observer = LangfuseObserver(client=client)
2795+
graph.attach_observer(observer)
27932796
state = _make_state_instance(case, state_cls)
27942797
caller_id = cast("str", case["caller_invocation_id"])
27952798
try:
27962799
await graph.invoke(state, invocation_id=caller_id)
27972800
await graph.drain()
27982801
finally:
2802+
observer.shutdown()
27992803
await provider.aclose()
28002804

28012805
assert len(client.traces) == 1, f"expected 1 Langfuse trace; got {len(client.traces)}"
@@ -3768,7 +3772,7 @@ def _assert_langfuse_observation_tree(
37683772
# Mutable copy: each matched observation is consumed so two
37693773
# same-shape expected siblings can't both bind to one actual.
37703774
remaining = list(trace.children_of(parent_id))
3771-
use_matcher = bindings is not None or params is not None
3775+
use_matcher = bindings is not None and params is not None
37723776
for exp in expected:
37733777
exp_type = cast("str", exp["type"])
37743778
exp_name = cast("str | None", exp.get("name"))

0 commit comments

Comments
 (0)