Commit 4f1f440
fix(anthropic_sdk): preserve empty tool output + harden token test
Two more reviewer-flagged issues:
1. _call_tool_result_to_text() dropped empty TextContent
The truthy check 'if text:' treated TextContent(text='') the same as
text=None and skipped it. With an only-empty content list, parts
would be [] and the helper fell through to the str(result) fallback
(which is a noisy repr of the result object) instead of returning
the actual empty result the tool reported. Fix: 'if text is not
None:' preserves explicit empty strings; the str(result) fallback
now only fires when there are no text-bearing blocks at all.
2. test_build_raises_bad_request_when_no_token_available was flaky
The test cleared a long list of API key env vars (defensive cargo
cult) but missed COPILOT_TOKEN, which is the second variable that
capi.get_AI_token() consults. On runners with COPILOT_TOKEN set
(e.g. CI envs authed to Copilot), the test would unexpectedly find
a token and the assertion would fail. Simplified to clear only the
two vars the chain actually consults: AI_API_TOKEN and COPILOT_TOKEN.
+2 regression tests for empty-string preservation; 291 passing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 5e0a38c commit 4f1f440
2 files changed
Lines changed: 36 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
61 | 67 | | |
62 | | - | |
| 68 | + | |
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
196 | 215 | | |
197 | 216 | | |
198 | 217 | | |
| |||
480 | 499 | | |
481 | 500 | | |
482 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
483 | 506 | | |
484 | 507 | | |
485 | 508 | | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
490 | 514 | | |
491 | 515 | | |
492 | 516 | | |
| |||
0 commit comments