Skip to content

fix(runtime): skip empty persisted assistant turns when reconstructin… - #27

Merged
lg2m merged 1 commit into
refactor/h21-settle-runfrom
fix/empty-assistant-turn-follow-up
Sep 12, 2026
Merged

lg2m merged 1 commit into
refactor/h21-settle-runfrom
fix/empty-assistant-turn-follow-up

Conversation

@lg2m

@lg2m lg2m commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

…g a conversation

A completed turn can persist an assistant message with no model-visible content (reasoning-only, or a call-less empty completion). The live turn loop already skips those, but the reconstructed history for a follow-up on that session did not, so the run failed with "conversation messages must not be empty" before reaching the provider.

usable_conversation drops content-less messages and, when the drop would leave two same-role messages adjacent, inserts a runtime-notice placeholder so providers that require alternation still accept the request. Regression tests cover the in-process runtime and the durable session path.

…g a conversation

A completed turn can persist an assistant message with no model-visible
content (reasoning-only, or a call-less empty completion). The live turn
loop already skips those, but the reconstructed history for a follow-up
on that session did not, so the run failed with "conversation messages
must not be empty" before reaching the provider.

usable_conversation drops content-less messages and, when the drop would
leave two same-role messages adjacent, inserts a runtime-notice
placeholder so providers that require alternation still accept the
request. Regression tests cover the in-process runtime and the durable
session path.
@lg2m
lg2m added this pull request to stack #29 September 12, 2026 03:51
@lg2m
lg2m merged commit 1747435 into main Sep 12, 2026
8 checks passed
@lg2m
lg2m deleted the fix/empty-assistant-turn-follow-up branch September 12, 2026 05:11
@lg2m lg2m mentioned this pull request Sep 14, 2026
lg2m added a commit that referenced this pull request Sep 22, 2026
…n instead of failing the run (RR2) (#116)

A prompt such as `/clear` or `/agents` that the TUI did not own was
forwarded to the runtime, admitted, and then failed inside the run loop
with InvalidCommand, leaving a failed run row whose "The previous run
failed" notice opened the operator's next real prompt. Three runs in the
2026-09-21 audit; the other five in that bucket were the pre-#27 empty
conversation bug and have not recurred.

SessionCommand::SubmitPrompt now validates the rendered prompt's leading
name against the grammar and RESERVED_CLIENT_SLASH_COMMANDS before any row
is written (no I/O; the workspace index is not consulted) and refuses with
SessionRuntimeError::InvalidSlashCommand(SlashCommandError), which the
server maps to InvalidRequest and headless to InvalidConfiguration. The TUI
already returns the text to the composer on a refused command. `//` still
escapes to literal text, and an unknown but well-formed name still fails
the run because only the workspace index can decide it.

`/clear` joins the client vocabulary as an alias of `/new` (constant grows
20 -> 21 entries; additive, no PROTOCOL_VERSION bump).

Tests: unresolvable_slash_prompts_are_refused_at_admission_without_a_run_row
(three refusals, one escaped prompt, exactly one run, completed);
slash_clear_is_a_client_alias_for_a_new_session.
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