picoclaw/pkg/providers
Liqiang Liu f81b44bf19
fix(provider): deduplicate tool results and merge consecutive tool_result blocks for Anthropic API (#1793)
Anthropic API returns 400 when multiple tool_result blocks share the same
tool_use_id, or when consecutive tool results are sent as separate user
messages. This fix:

1. Adds ToolCallID deduplication in sanitizeHistoryForProvider (context.go)
   to drop duplicate tool results before sending to any provider.
2. Merges consecutive tool result messages into a single user message with
   multiple tool_result content blocks in Anthropic's buildRequestBody,
   for both "user" (with ToolCallID) and "tool" role messages.
3. Adds tests for both behaviors.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 17:24:46 +08:00
..
anthropic fix(anthropic): skip tool calls with empty names to prevent API errors (#1739) 2026-03-18 21:55:01 +08:00
anthropic_messages fix(provider): deduplicate tool results and merge consecutive tool_result blocks for Anthropic API (#1793) 2026-03-23 17:24:46 +08:00
azure fix(provider/azure): lint err 2026-03-15 12:45:11 +08:00
common Merge pull request #1891 from RussellLuo/audio-transcription 2026-03-23 00:23:30 +01:00
openai_compat feat(providers): add extra_body config to inject custom fields into request body 2026-03-23 16:39:42 +08:00
protocoltypes feat(providers): add Media field to Message struct for vision support 2026-03-03 16:27:29 +08:00
antigravity_provider.go fix: handle ignored io.ReadAll errors across codebase 2026-03-05 20:56:38 +09:00
antigravity_provider_test.go fix(antigravity): normalize tool calls to avoid empty function names 2026-02-17 20:05:35 +05:30
claude_cli_provider.go fix(claude_cli): surface stdout in error when CLI exits non-zero 2026-03-12 22:01:56 -04:00
claude_cli_provider_integration_test.go feat(fmt): Run formatters 2026-02-18 21:48:23 +02:00
claude_cli_provider_test.go refactor: seperate security.yml for store keys 2026-03-22 01:55:00 +08:00
claude_provider.go feat(fmt): Run formatters 2026-02-18 21:48:23 +02:00
claude_provider_test.go feat(fmt): Fix formatting 2026-02-20 20:03:11 +02:00
codex_cli_credentials.go refactor: centralize environment variable key constants (#1730) 2026-03-18 18:03:24 +08:00
codex_cli_credentials_test.go enable dogsled 2026-02-25 21:14:19 +11:00
codex_cli_provider.go remove wrapper methods 2026-03-01 18:24:11 +11:00
codex_cli_provider_integration_test.go feat(fmt): Run formatters 2026-02-18 21:48:23 +02:00
codex_cli_provider_test.go refactor: update model name and add VolcEngine coding plan (#1412) 2026-03-12 16:10:29 +08:00
codex_provider.go Add model-native search (prefer_native) for OpenAI/Codex (#1618) 2026-03-18 11:55:30 +08:00
codex_provider_test.go Add model-native search (prefer_native) for OpenAI/Codex (#1618) 2026-03-18 11:55:30 +08:00
cooldown.go style: fix gofmt formatting in cooldown files 2026-02-13 12:26:44 -03:00
cooldown_test.go refactor(modernize): apply safe modernize fixes 2026-02-27 16:35:07 +08:00
error_classifier.go fix(pkg):do regex precompile insteadd on the fly (#911) 2026-03-01 23:06:31 +11:00
error_classifier_test.go fix(pkg):do regex precompile insteadd on the fly (#911) 2026-03-01 23:06:31 +11:00
factory.go refactor Config to add Version and migratable 2026-03-12 13:52:55 +08:00
factory_provider.go Use getter/setter methods for API key access in ModelConfig 2026-03-23 16:39:43 +08:00
factory_provider_test.go Use getter/setter methods for API key access in ModelConfig 2026-03-23 16:39:43 +08:00
factory_test.go refactor: seperate security.yml for store keys 2026-03-22 01:55:00 +08:00
fallback.go feat(config): support multiple API keys for failover (#1707) 2026-03-19 00:57:20 +08:00
fallback_multikey_test.go feat(config): support multiple API keys for failover (#1707) 2026-03-19 00:57:20 +08:00
fallback_test.go feat(config): support multiple API keys for failover (#1707) 2026-03-19 00:57:20 +08:00
github_copilot_provider.go fix: improve error handling in GitHub Copilot provider (#919) 2026-03-01 22:58:41 +11:00
http_provider.go feat(providers): add extra_body config to inject custom fields into request body 2026-03-23 16:39:42 +08:00
legacy_provider.go refactor Config to add Version and migratable 2026-03-12 13:52:55 +08:00
model_ref.go feat(provider): add Alibaba Coding Plan and regional Qwen endpoints (#1748) 2026-03-19 22:07:30 +08:00
model_ref_test.go feat(provider): add Alibaba Coding Plan and regional Qwen endpoints (#1748) 2026-03-19 22:07:30 +08:00
tool_call_extract.go feat(fmt): Run formatters 2026-02-18 21:48:23 +02:00
toolcall_utils.go enable dupl check 2026-03-01 18:17:32 +11:00
types.go feat(telegram): stream LLM responses via sendMessageDraft (#1101) 2026-03-20 21:04:14 +08:00