Repository navigation
feat(agui): carry the next-step suggestion on the AG-UI run state - #1712
Merged
Merged
Conversation
The serve worker seeds a nextStepSuggestion state key on every AG-UI run and patches it with the ChatSuggestionGenerator line before the terminal event, so AG-UI clients such as the desktop app get the after-turn suggestion the chat TUI shows as ghost text. The generator is reused through a headless Services accessor with the same silent-fail semantics as the TUI, and the suggestion call's tokens land in the session usage the run already reports.
This was referenced Nov 6, 2026
inference-gateway-maintainer
Bot
marked this pull request as ready for review
November 6, 2026 16:00
inference-gateway-maintainer
Bot
requested a review
from a team
as a code owner
November 6, 2026 16:00
…cellable The serve run asked for a suggestion under context.Background, so worker shutdown could not stop it. It now runs under the turn's context, and a turn with a queued message or a subagent's worker asks for none. The chat TUI got a typed nil pointer as its suggestion runner on a daemon thread, which defeated its nil check. It gets a nil interface again.
The run encoder kept its own failure field next to the error the AG-UI run already holds. The run now exposes Err and the encoder asks it, so the suggestion follows the outcome of the run that ends. The suggestion tests no longer share a counter across rows, and a row pins that a container building no generator suggests nothing.
Contributor
|
🎉 This PR is included in version 0.246.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Resolves #1710
Summary
AG-UI runs in --serve mode now carry the same one-line next-step suggestion the chat TUI shows as ghost text after an assistant turn (the feature of #1546). The serve run patches a new
nextStepSuggestionstate key just before its terminal event, so an AG-UI client such as the desktop app (tracked in inference-gateway/desktop#439) can offer the same suggestion.ChatSuggestionGeneratoris reused as-is through a headlessServicesaccessor, so disabled, failed, timed-out and discarded suggestions stay silent-fail, the daemon-threadnilcase stays a no-op, and the suggestion call's tokens land in the session totals the run already reports in itsusagestate andRUN_FINISHEDresult.Changes
internal/protocols/agui/run.go: newnextStepSuggestionstate key seeded""inseedState, so everySTATE_SNAPSHOTalways carries itinternal/presentation/headless/run_encoder.go:RunEncodertakes an optionalSuggestNextStepsource and patches its suggestion into the run state before the terminal event, withFinishordering the patch ahead ofRUN_FINISHED/RUN_ERROR. A failed or cancelled run, an unwired source and an empty suggestion publish nothing (same silent-fail semantics as the TUI)internal/presentation/headless/serve.go: the serve run wires the generator in viasvc.GetNextStepSuggestionRunner().GenerateNextStepSuggestioninternal/presentation/headless/headless.go: the headlessServicesinterface gains the accessor, returning the concrete generatorinternal/container/container.go:GetNextStepSuggestionRunnerreturns*conversation.ChatSuggestionGeneratorso the TUI contract and the headlessServicescontract share the one accessor, with the daemon-threadnilcase unchangedinternal/presentation/headlesscover the published patch before the terminal event, the disabled/unwired/empty cases (no patch) and a failed run (the generator is never even asked). Theinternal/protocols/aguiseeded-state tests now check the new keydocs/ag-ui-output.mdlists the state key in the event mapping and State sectionsNo downstream schema change: the key is the CLI's own run state, so only AG-UI clients read it. The desktop side is tracked in inference-gateway/desktop#439.