llm-gateway/sync/history/2026-05-12-claude-tool-adapter.md
2026-05-12 23:09:58 +02:00

1.4 KiB

2026-05-12 — Claude Tool Adapter

Summary

The local Gateway Companion now has a bounded Anthropic tool-use adapter for Claude Code traffic.

What Changed

  • Anthropic request tools are rendered into a strict instruction for the text backend.
  • OpenAI-style tool calls and compact JSON tool decisions are converted into Anthropic tool_use blocks.
  • Forced tool_choice: {type:"tool"} returns a valid tool_use block even when the text backend returns an empty response.
  • Streaming tool use emits Anthropic-compatible SSE:
    • message_start
    • content_block_start
    • content_block_delta with input_json_delta
    • content_block_stop
    • message_delta
    • message_stop

Verification

  • Non-stream synthetic request:
    • Tool: read_file
    • Result: content[0].type=tool_use
    • Input: {"path":"/tmp/hello.txt"}
  • Streaming synthetic request:
    • Tool: read_file
    • Result: input_json_delta
    • Input: {"path":"/tmp/stream.txt"}
  • Claude Code CLI smoke after the change still reached the Gateway and produced dashboard rows for claude-code-companion.

Boundary

The Erik claude-bridge remains text-only and calls claude --print --output-format text. Native hosted Anthropic tool-use parity is not complete. The adapter now transports and synthesizes tool blocks for forced tool calls, but autonomous tool selection still depends on the text backend following the JSON tool instruction.