#2924·ag-ui

[错误]: Claude 代理 SDK Python 在仅显示前端工具后发送空白提示

作者: contextablemark创建于 2026年10月1日更新于 2026年10月1日

Claude Agent SDK Python: avoid blank prompts after display-only frontend tools Python parity follow-up to #2923; this does not block approval of the TypeScript fix. When a display-only frontend tool completes with an empty or whitespace-only result, the Python adapter still forwards that content as a blank SDK prompt. The TypeScript fix in #2923 supplies a plain-text completion message for this case. Verified on PR #2923's HEAD and current main ec28a110b71acba229cada5cf15bf15bb5324825: - process_messages preserves string content unchanged and only warns when it is empty. - run converts the prompt, then submits it to the per-thread worker. - SessionWorker calls client.query(prompt, session_id=session_id) without replacing blank prompts. - The frontend MCP stub returns Tool call forwarded to client, matching the TypeScript adapter's existing approach. ## Reproduction evidence A dependency-free AST extraction executed the actual process_messages function with a user message, assistant tool call, and trailing tool result. Results were identical at both revisions: | Tool result content | Returned prompt | Pending tool result | | --- | --- | --- | | "" | "" | True | | " \n" | " \n" | True | | '{"ok":true}' | '{"ok":true}' | True | This reproduces prompt conversion. The subsequent submission path was traced in source; no live Claude SDK/API request or provider rejection was reproduced. ## Acceptance criteria - Empty and whitespace-only trailing tool results yield a nonempty plain-text completion prompt, consistent with #2923. - Include the matching tool name and call ID when available, and tolerate a missing assistant declaration. - Preserve nonempty tool results and existing user/multimodal conversion behavior. - Add regression tests for conversion and a follow-up run on a reused per-thread worker, asserting the fallback reaches the SDK query boundary.

内容来源: ag-ui-protocol/ag-ui