Repository navigation
fix(runtime): skip empty persisted assistant turns when reconstructin… - #27
Merged
Merged
Conversation
…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.
Merged
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…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.