Commit 07df4b7
committed
fix(teams): commit accumulated text only after successful _teams_send
Address Codex P2 finding on PR #88. The previous flow updated
``accumulated`` and ``session.sequence`` BEFORE awaiting ``_teams_send``,
so a 429/network failure mid-stream would leave the partial RawMessage
returned to the caller (and ``session._text`` feeding the final close-
activity) carrying text that Teams never displayed to the user.
Fix:
- Build ``candidate_accumulated = accumulated + text`` and
``next_sequence = session.sequence + 1`` as candidates.
- Send the activity with the candidate values.
- Commit ``accumulated`` and ``session.sequence`` only after the send
succeeds.
The soft-cancel path (logged warn + session.cancel + break) now
genuinely returns the high-water mark of successfully-sent text. Matches
the documented "RawMessage carries pre-failure content" guarantee in
``docs/UPSTREAM_SYNC.md`` non-parity table.
Updated test_emit_send_failure_cancels_session: previously asserted
``result.raw["text"] == "helloworld"`` (which contained the rejected
"world" chunk); now asserts ``"hello"`` and ``session.sequence == 1``.
Skipped Codex P2 #2 (active_streams clobber timing) — matches upstream
TS behavior; deferring fix as a Python-only improvement would be a
divergence and is design-significant. File as follow-up if desired.
23 native-streaming tests pass.
https://claude.ai/code/session_01FyMxQn2BEAzmwKS1GZczKj1 parent 2e96fbb commit 07df4b7
2 files changed
Lines changed: 43 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1141 | 1141 | | |
1142 | 1142 | | |
1143 | 1143 | | |
1144 | | - | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
1145 | 1151 | | |
1146 | 1152 | | |
1147 | 1153 | | |
1148 | 1154 | | |
1149 | 1155 | | |
1150 | | - | |
| 1156 | + | |
1151 | 1157 | | |
1152 | 1158 | | |
1153 | | - | |
| 1159 | + | |
1154 | 1160 | | |
1155 | 1161 | | |
1156 | 1162 | | |
| |||
1160 | 1166 | | |
1161 | 1167 | | |
1162 | 1168 | | |
1163 | | - | |
| 1169 | + | |
1164 | 1170 | | |
1165 | 1171 | | |
1166 | 1172 | | |
1167 | 1173 | | |
1168 | 1174 | | |
1169 | | - | |
| 1175 | + | |
1170 | 1176 | | |
1171 | 1177 | | |
1172 | 1178 | | |
| |||
1177 | 1183 | | |
1178 | 1184 | | |
1179 | 1185 | | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
1183 | 1191 | | |
1184 | 1192 | | |
1185 | 1193 | | |
1186 | 1194 | | |
1187 | 1195 | | |
1188 | 1196 | | |
1189 | 1197 | | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
1190 | 1202 | | |
1191 | 1203 | | |
1192 | 1204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
398 | 408 | | |
399 | 409 | | |
400 | 410 | | |
| |||
416 | 426 | | |
417 | 427 | | |
418 | 428 | | |
419 | | - | |
420 | | - | |
421 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
422 | 441 | | |
423 | 442 | | |
424 | 443 | | |
| |||
0 commit comments