Commit 77aa819
committed
fix(ai): bypass SDK MessageStream to prevent partialParse JSON crash
Switch from client.messages.stream() to client.messages.create() to avoid
the Anthropic SDK's unguarded partialParse() call in MessageStream, which
crashes with 'Expected , or } after property value in JSON' or 'Bad control
character in string literal' when tool input JSON contains control characters
or triggers the vendored partial-json tokenizer's consecutive string token bug.
Pi already accumulates tool arguments with its own parseStreamingJson() which
handles all these cases gracefully. The SDK's MessageStream accumulation was
redundant and its partialParse crash killed the entire stream before pi ever
saw the event. The raw Stream from .create() yields identical SSE events
without the buggy accumulation layer.
Upstream: anthropics/anthropic-sdk-typescript#971 (open, unmerged)
Related: anthropics/anthropic-sdk-typescript#882
Related: anthropics/anthropic-sdk-python#12651 parent 2e66aeb commit 77aa819
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| |||
0 commit comments