Skip to content

fix: skip empty assistant turns instead of placeholder space#560

Merged
tlongwell-block merged 1 commit into
mainfrom
fix/anthropic-skip-empty-assistant-turn
May 13, 2026
Merged

fix: skip empty assistant turns instead of placeholder space#560
tlongwell-block merged 1 commit into
mainfrom
fix/anthropic-skip-empty-assistant-turn

Conversation

@tlongwell-block
Copy link
Copy Markdown
Collaborator

Follow-up to #559.

Instead of emitting " " (single space) as a placeholder for empty assistant turns, skip them entirely. An assistant turn with no text and no tool calls carries zero information — no tool_use means no tool_result pairing constraint, so omitting is safe.

This matches the canonical pattern used by litellm, goose (anthropic.rs line 124), and other Anthropic API consumers: strip empty content at serialization time rather than patching with placeholders.

Research

The " " placeholder from #559 works but is a band-aid. anthropics/anthropic-sdk-python#461 (April 2024) confirmed this validation is intentional and has existed since the tool use beta. The Anthropic maintainer's guidance: empty text blocks should be filtered, not patched.

Change

llm.rs: replace content.push(json!({"type":"text","text":" "})) with continue (skip the turn).

Follow-up to #559. Instead of emitting a ' ' placeholder for empty
assistant turns, skip them entirely. An assistant turn with no text
and no tool calls carries zero information — no tool_use means no
tool_result pairing constraint, so omitting is safe.

This matches the canonical pattern used by litellm, goose, and other
Anthropic API consumers: strip empty content at serialization time.
@tlongwell-block tlongwell-block merged commit 90063cf into main May 13, 2026
15 checks passed
@tlongwell-block tlongwell-block deleted the fix/anthropic-skip-empty-assistant-turn branch May 13, 2026 13:40
tlongwell-block added a commit that referenced this pull request May 13, 2026
* origin/main:
  chore(acp): raise default idle timeout from 320s to 620s (#566)
  fix(cli): derive thread root from parent event tags (#564)
  fix: skip empty assistant turns instead of placeholder space (#560)

Signed-off-by: Tyler Longwell <109685178+tlongwell-block@users.noreply.github.com>
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.

1 participant