Skip to content

Send no ACP message chunk for empty assistant text - #100

Open
conornash wants to merge 1 commit into
lambda-symbolics:masterfrom
conornash:acp-skip-empty-message-chunks
Open

conornash wants to merge 1 commit into
lambda-symbolics:masterfrom
conornash:acp-skip-empty-message-chunks

Conversation

@conornash

Copy link
Copy Markdown

Last one, and hopefully the most useful. Using Autolith through agent-shell in Emacs, with DeepSeek via OpenRouter, every word of the model's reasoning showed up as its own "Thought" block. It turned out Autolith was sending an empty message chunk alongside each piece of reasoning. I've checked the fix in agent-shell, where a reply now shows a single Thought block instead of one per word.

The below is the agent explanation of what this PR does:

With DeepSeek via OpenRouter, agent-shell showed a separate "Thought" block for every word of the model's reasoning.

The provider stream carries a reasoning delta and a content delta in each event, and the content is "" while the model is still thinking. agent-observer-reasoning on acp-observer skips empty text, but agent-observer-text did not, so every reasoning fragment was followed by an empty agent_message_chunk on the wire:

agent_thought_chunk  {"text":"The"}
agent_message_chunk  {"text":""}
agent_thought_chunk  {"text":" user asks a"}
agent_message_chunk  {"text":""}

The empty message flushed agentcomms' thought batching, and agent-shell treats any agent_message_chunk as the end of a thought run, so it opened a new thought group per fragment.

agent-observer-text now sends nothing for empty text, as agent-observer-reasoning already does. Appending empty text never changed the streamed-text record used for nonstreamed reconciliation.

test-acp-observer-skips-empty-message-text interleaves empty text with reasoning fragments and expects one coalesced thought chunk and no message chunk; it failed on both assertions before the change. The acp suite passes: 46 cases, 333 checks.

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