Commit 40c09d8
fix(codex): set tailer emitted flag before send to close scale-flap race
The rollout token tailer stored its emitted flag after sending each Tokens
event, leaving a window where a consumer observed the tailer's cumulative
Tokens while emitted was still false. A concurrent turn.completed envelope
then read the flag as false and leaked a per-turn-scale token value, flapping
the live counter between per-turn and session-cumulative scales and making the
final value nondeterministic. Store before the send so the flag is observable
no later than the Tokens event itself.
Fixes flaky TestParseCodexOutput_TailerSuppressesPerTurnStdoutTokens.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 01KYKXTGZF3PAB8PKZTYERN2D71 parent b0fd1e7 commit 40c09d8
1 file changed
Lines changed: 13 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
129 | 138 | | |
130 | 139 | | |
131 | 140 | | |
132 | | - | |
133 | 141 | | |
| 142 | + | |
134 | 143 | | |
135 | 144 | | |
136 | 145 | | |
| |||
0 commit comments