Skip to content

fix: repair Anthropic native tool traces bug#42

Merged
chenyme merged 1 commit into
devfrom
anthropic_tool
May 24, 2026
Merged

fix: repair Anthropic native tool traces bug#42
chenyme merged 1 commit into
devfrom
anthropic_tool

Conversation

@chenyme

@chenyme chenyme commented May 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix native web search protocol handling so Anthropic server-side tools are not confused with local MCP tools, and tool traces keep request and response details consistently.

Anthropic native tools are now classified separately from MCP tools. If an Anthropic-compatible upstream returns a native tool such as web_search as a client-side tool_use, the run now fails with a clear protocol error instead of trying to execute it through MCP. Anthropic server-side tool result blocks are also merged into the same trace entry, with opaque encrypted result fields removed. OpenAI Responses web search now requests web_search_call.action.sources by default, and the frontend trace renderer shows web search request and response sections consistently.

Change type

  • Bug fix
  • Feature
  • Documentation
  • Refactor
  • Configuration / deployment
  • Security hardening
  • Other

Affected areas

  • Frontend / UI
  • Backend / API
  • Authentication / authorization
  • Conversations / streaming
  • Files / RAG / extraction
  • Model routing / providers
  • MCP / tools
  • Billing / payments
  • Admin console
  • Deployment / Docker / configuration
  • Documentation

Verification

  • cd backend && go test ./internal/infra/llm
  • cd backend && go test ./internal/application/conversation
  • cd backend && go test ./...
  • cd frontend && pnpm lint features/chat/components/message/message-process-trace.tsx
  • cd frontend && pnpm build
  • git diff --check

Screenshots, API examples, or logs

Reported failure before the fix:

tool web_search is not enabled for this run

The failure was caused by an Anthropic-compatible upstream returning a Claude native server-side tool as a client-side tool_use.

Configuration, migration, and compatibility notes

Configuration changes: None.

API changes: No public API contract changes. Internal provider protocol handling and trace payloads were improved.

Database migrations: None.

Deployment changes: None.

Backward compatibility: Existing conversations remain readable. New runs now separate native provider tools from local MCP tools more strictly and produce clearer errors for invalid upstream protocol behavior.

Documentation

  • Documentation is not needed for this change.
  • Documentation was updated.
  • Documentation still needs to be updated.

Security and privacy

  • No secrets, tokens, credentials, local config, or personal data are included.
  • User data access remains scoped by authenticated user context unless an admin-only path explicitly requires broader access.
  • Security-sensitive behavior was reviewed, including authentication, authorization, provider routing, file processing, billing, and admin APIs where relevant.

Checklist

  • I searched existing issues and pull requests.
  • Changes are focused and do not include unrelated refactors.
  • Tests or static verification were run where practical.
  • User-facing behavior, deployment steps, API contracts, or configuration changes are documented.
  • Generated artifacts are included only when this project explicitly requires them.
  • Caches, build output, .pyc files, .env files, and local storage data are not committed.

@chenyme chenyme linked an issue May 24, 2026 that may be closed by this pull request
3 tasks
@chenyme
chenyme merged commit 08d7254 into dev May 24, 2026
2 checks passed
@chenyme
chenyme deleted the anthropic_tool branch May 24, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Claude 联网搜索重复调用并异常覆盖最终回复

1 participant