#2924·ag-ui

[Bug]: Claude Agent SDK Python sends blank prompts after display-only frontend tools

Author: contextablemarkCreated Oct 1, 2026Updated Oct 1, 2026

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:

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.