Skip to content

BUG: Emulated WebSearch ends before model synthesis #258

Description

@SimianW

Kiro Gateway Version

Current main at a5292ca (v2.4 development branch)

What happened?

When the Anthropic compatibility route auto-injects and intercepts the emulated web_search tool (Path B), the gateway executes the Kiro MCP search and emits Anthropic-compatible server_tool_use and web_search_tool_result blocks. It then appends a literal <web_search>...</web_search> summary as assistant text and ends the turn.

This differs from Anthropic server-tool behavior. The model never receives the search result, so it cannot synthesize an answer or continue the user's original task after deciding to search. Claude Code consequently displays the raw search dump as the assistant response.

Expected behavior:

  1. emit the server-tool blocks to the client;
  2. append the model's original web_search tool call and matching result to an internal conversation history;
  3. continue the same model internally;
  4. stream the model's natural answer or subsequent client-tool calls in the original Anthropic SSE message.

Internal continuation should be bounded to prevent search loops, preserve ordinary client tool calls, and fall back to the deterministic search summary if continuation fails.

Debug Logs

Sanitized behavior before the fix:

Intercepted web_search tool call (Path B - MCP emulation)
content blocks: server_tool_use, web_search_tool_result, text
assistant text: <web_search>...</web_search>
stop_reason: end_turn

No prompts, search queries, results, credentials, account identifiers, profile ARN values, local paths, or raw debug files are included.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions