@@ -672,11 +672,10 @@ def test_score_trace():
672672 trace = api_wrapper .get_trace (trace_id )
673673
674674 assert trace ["name" ] == trace_name
675- assert len (trace ["scores" ]) == 1
676675
677- score = trace [ " scores" ][ 0 ]
678-
679- assert score [ "name" ] == "valuation"
676+ # Find the score we created by name (server may create additional auto- scores)
677+ score = next (( s for s in trace [ "scores" ] if s [ "name" ] == "valuation" ), None )
678+ assert score is not None
680679 assert score ["value" ] == 0.5
681680 assert score ["comment" ] == "This is a comment"
682681 assert score ["observationId" ] is None
@@ -709,11 +708,10 @@ def test_score_trace_nested_trace():
709708 trace = get_api ().trace .get (trace_id )
710709
711710 assert trace .name == trace_name
712- assert len (trace .scores ) == 1
713711
714- score = trace . scores [ 0 ]
715-
716- assert score . name == "valuation"
712+ # Find the score we created by name (server may create additional auto- scores)
713+ score = next (( s for s in trace . scores if s . name == "valuation" ), None )
714+ assert score is not None
717715 assert score .value == 0.5
718716 assert score .comment == "This is a comment"
719717 assert score .observation_id is None # API returns this field name
@@ -753,11 +751,10 @@ def test_score_trace_nested_observation():
753751 trace = get_api ().trace .get (trace_id )
754752
755753 assert trace .name == trace_name
756- assert len (trace .scores ) == 1
757754
758- score = trace . scores [ 0 ]
759-
760- assert score . name == "valuation"
755+ # Find the score we created by name (server may create additional auto- scores)
756+ score = next (( s for s in trace . scores if s . name == "valuation" ), None )
757+ assert score is not None
761758 assert score .value == 0.5
762759 assert score .comment == "This is a comment"
763760 assert score .observation_id == child_span_id # API returns this field name
@@ -799,12 +796,11 @@ def test_score_span():
799796 # Retrieve and verify
800797 trace = api_wrapper .get_trace (trace_id )
801798
802- assert len (trace ["scores" ]) == 1
803799 assert len (trace ["observations" ]) == 1
804800
805- score = trace [ " scores" ][ 0 ]
806-
807- assert score [ "name" ] == "valuation"
801+ # Find the score we created by name (server may create additional auto- scores)
802+ score = next (( s for s in trace [ "scores" ] if s [ "name" ] == "valuation" ), None )
803+ assert score is not None
808804 assert score ["value" ] == 1
809805 assert score ["comment" ] == "This is a comment"
810806 assert score ["observationId" ] == span_id
0 commit comments