Commit 02cd094
committed
fix(anthropic): handle plain string content in part_to_message_block
When a tool returns a response where the "content" key holds a plain
string, part_to_message_block() was iterating over it directly. Since
strings are iterable in Python, the loop produced one character per
iteration instead of the full text.
LoadSkillResourceTool is a concrete case: it returns a response dict
with a "content" key that is a string, not a list.
The fix adds an isinstance check before the loop. When content is a
string it is used directly. When it is a list, the existing join
logic runs unchanged. A unit test covers both paths.
Fixes #53581 parent 69fa777 commit 02cd094
2 files changed
Lines changed: 37 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
201 | 201 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
208 | 214 | | |
209 | | - | |
210 | 215 | | |
211 | | - | |
212 | | - | |
213 | | - | |
| 216 | + | |
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
776 | 776 | | |
777 | 777 | | |
778 | 778 | | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
779 | 802 | | |
780 | 803 | | |
781 | 804 | | |
| |||
0 commit comments