Commit 6145781
committed
fix(e2e): derive mock stage from request body, not a call counter
Review feedback: the global _STATE["calls"] counter was incremented
unlocked and before the response was emitted. Two failure modes follow —
ThreadingHTTPServer can serve requests concurrently, and an aborted or
retried call consumed the tool stage, leaving the retry to receive the
final message instead. Reproduced the latter: aborting call 1 mid-stream
made the retry return output_text rather than re-emitting function_call,
which would surface as a bare 'no tool spans' failure.
The conversation already carries the stage, so read it instead of
counting: turn 1 has only the user message, turn 2 carries the tool
result (function_call_output on the Responses wire, role: "tool" on
Chat Completions). That is idempotent — a retry resends the same body
and gets the same stage — so the mutable global goes away entirely
rather than being guarded by a lock.
Verified: the retry now re-emits function_call; both wires stage
correctly on turns 1 and 2; mock E2E passes on latest, v2026.7.30 and
v2026.7.20; wheel and real-Opik E2E pass; 113 unit tests pass.1 parent 6e1729e commit 6145781
1 file changed
Lines changed: 36 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | | - | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
43 | 71 | | |
44 | 72 | | |
45 | 73 | | |
| |||
186 | 214 | | |
187 | 215 | | |
188 | 216 | | |
189 | | - | |
190 | 217 | | |
191 | | - | |
192 | | - | |
193 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
194 | 221 | | |
195 | 222 | | |
196 | 223 | | |
| |||
204 | 231 | | |
205 | 232 | | |
206 | 233 | | |
207 | | - | |
208 | | - | |
| 234 | + | |
209 | 235 | | |
210 | 236 | | |
211 | 237 | | |
| |||
0 commit comments