Repository navigation
fix(ai): skip JSON parse for Anthropic streamed tool calls without arguments - #5764
pcbeingused333 wants to merge 1 commit into
Conversation
SDK performance: posthog-node1 change worth reviewing: 1 observed improvement. Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate.
View all results
Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals. Each shard uses its own runner; compare Before PR against With PR within a row, not across shards. Compared 102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in |
Problem
When an Anthropic streamed response calls a tool that takes no arguments, Claude sends no
input_json_deltaevents, so the accumulatedinputStringis''. Atcontent_block_stopthe wrapper callsJSON.parse(''), which throws, and logsError parsing tool input: SyntaxError: Unexpected end of JSON inputviaconsole.erroron every such call. The capturedargumentsalready stays{}, so the only effect is noisy logs in the user's app.Changes
argumentskeeps its default{}. Invalid non-empty JSON still logs as before.tests/anthropic.test.ts: a streamed no-argument tool call must not callconsole.error. It fails without the change and passes with it.@posthog/ai(patch).Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
@posthog/aivitest suitetests/anthropic.test.ts(no live API calls): 1 failure with the previous code, all pass with the fix. No manual testing against the live API.