Repository navigation
Description
Summary
The chat TUI shows a one-line next-step suggestion as ghost text in the empty input after an assistant turn completes (#1546). The AG-UI run that infer renders in --serve mode never carries it, so an AG-UI client such as the desktop app cannot offer the same suggestion. Expose the suggestion on the AG-UI protocol so a client can render it.
Current state, verified in the code:
internal/conversation/chat_suggestion_generator.go-ChatSuggestionGenerator.GenerateNextStepSuggestionbuilds the prompt from the lastchat.suggestions.context_messagesentries, calls the configured model withSkipMCP, records token usage on the session, and returns a sanitized single line (max 80 chars) or""on any failure. It is independent of the TUI.internal/container/container.go-GetNextStepSuggestionRunnerbuilds it lazily and returnsnilwhen the container is attached to a daemon thread. Onlycmd/chat/program.gocalls it.internal/presentation/tui/handlers/chat_handler.go- the TUI requests it fromHandleSuggestionQuietEventafter a quiet window once the agent is idle, the input is empty and the queue is empty, and dismisses it on the next user action.internal/presentation/headless/serve.goandrun_encoder.go-serveTurnrenders the run andRunEncoder.Handlemaps everyChatEvent, but nothing calls the generator. The run's state keys ininternal/protocols/agui/run.goaretodos,usage,backgroundTasks,screenRecordingandscreenControl, all seeded byseedStateso everySTATE_SNAPSHOTcarries all keys.config/config.go-ChatSuggestionsConfig(chat.suggestions.enabled,model,context_messages,max_tokens,timeout) withEffectiveSuggestionsdefaults.
Proposed shape: add a nextStepSuggestion state key (seeded "") that the serve worker patches with the generated line after the agent loop ends and before the run's terminal event, so a client receives it as a STATE_DELTA on the same run. Reuse ChatSuggestionGenerator as-is through a headless Services accessor. An empty suggestion (disabled, failed, discarded) patches nothing. The desktop side is tracked in inference-gateway/desktop#439.
Acceptance Criteria
-
internal/protocols/agui/run.godefines anextStepSuggestionstate key seeded with""inseedState, so aSTATE_SNAPSHOTalways carries it. - In
--servemode, whenchat.suggestions.enabledis true and the run ended with an assistant turn, the run publishes the sanitized suggestion as aSTATE_DELTApatch ofnextStepSuggestionbeforeRUN_FINISHED. - A disabled, failed, timed-out or discarded suggestion publishes nothing and never fails the run (same silent-fail semantics as the TUI).
- The suggestion call's tokens land in the session totals the run already reports in its
usagestate andRUN_FINISHEDresult. -
ChatSuggestionGeneratoris reused, not duplicated - the headlessServicesinterface gains an accessor for it and the daemon-threadnilcase stays a no-op. - Tests in
internal/presentation/headlesscover the published patch, the disabled case and a failing generator (the AG-UI run tests inrun_encoder_test.goshow the pattern). -
docs/ag-ui-output.mdlists the new state key next to the existing ones.
Related: #1546 (ghost text suggestion in the TUI, closed).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
edenreich commentedon Nov 6, 2026
@infer can you work on this? use /ponytail:ponytail /domain-driven-design /clean-architecture /clean-code /go /go-concurrency /bubbles-v2
Check also if our current TUI uses the AG-UI protocol, if not please create a follow-up github refactoring request.
inference-gateway-maintainer commentedon Nov 6, 2026
Model:
ollama_cloud/glm-5.3-flash· Action:v0.59.4· CLI:v0.244.0· Gateway:v0.63.1· View JobTodos
Pull Request
#1712
✅ Infer Result: Success
Done. The next-step suggestion now travels on the AG-UI run state, so the desktop app can offer it the way the TUI does.
PR: #1712 feat(agui): carry the next-step suggestion on the AG-UI run state (ready for review,
Resolves #1710, board set to QA)What shipped, matching the acceptance criteria:
internal/protocols/agui/run.godefinesStateNextStepSuggestion = "nextStepSuggestion"and seeds it with""inseedState, so everySTATE_SNAPSHOTalways carries the key (the seeded-state tests inrun_test.gonow check it too).RunEncodertakes an optionalSuggestNextStepsource and patches its suggestion into the run state before the terminal event;RunEncoder.Finish()emits the patch ahead ofRUN_FINISHED, and the source's tokens land in the repo beforesessionUsage/sessionExtrasare read, so the terminal event carries them.serveTurn) wires the generator in assvc.GetNextStepSuggestionRunner().GenerateNextStepSuggestion. A failed or cancelled run never asks the generator (it is recorded via the encoder'sfail), and an empty suggestion patches nothing, which is the TUI's silent-fail semantics. One-shot--format ag-uiruns and--keep-aliveruns get no source and stay unchanged.ChatSuggestionGeneratoritself is untouched and reused: the headlessServicesinterface gained the accessor and the container returns the concrete*conversation.ChatSuggestionGenerator, so the TUI contract (tui.NextStepSuggestionRunner) and the headless contract share one accessor, with the daemon-threadnilcase unchanged.internal/presentation/headlesscover the published patch before the terminal event, the disabled/unwired/empty cases (no patch on/nextStepSuggestion), and a failed run (the generator is never even asked).docs/ag-ui-output.mdlists the state key in the event mapping and State tables.go build ./..., targetedgo test, and the fulltask precommit:rungate.On your question about the TUI and AG-UI: the chat TUI does not render its own runs through the AG-UI protocol. It maps
agentdomain.ChatEvents through its own handlers ininternal/presentation/tui/handlers, none of which importprotocols/agui; the TUI only touches AG-UI as a wire client when following a daemon thread (daemonthread/thread.go), while the serve worker and daemon binding share theRunEncoder/protocols/aguimapping. I filed follow-up #1713 (refactor request) to unify the TUI's rendering with the AG-UI event model so features land for every view at once. Because this changes public-facing behavior, I also opened a[DOCS]ticket in the docs repo: inference-gateway/docs#1101. No downstream schema change - the key is the CLI's own run state, and the desktop side remains tracked in inference-gateway/desktop#439.Skipped: I did not run the e2e suite (
-tags e2e, needs a TestMain binary build) since the unit tests and lint gate cover the changed packages, and one-shot--format ag-uiruns deliberately do not get suggestions (serve-only scope per the issue). Risk: the suggestion LLM call is synchronous inside the serve run, soRUN_FINISHEDwaits up tochat.suggestions.timeoutfor it, and desktop clients must read the state key (not an event they may already expect) per docs#1101.Model:
ollama_cloud/glm-5.3-flash· Action:v0.59.4· CLI:v0.244.0· Gateway:v0.63.1· Exit Code:0· Duration: 10m 27sTokens: 6,433,041 in · 49,620 out · 6,482,661 total (47 requests)
Tool calls: 91 total · 100% success rate
Traces
Stats
Triggered by edenreich · Infer Action · OSS
inference-gateway-releaser commentedon Nov 7, 2026
🎉 This issue has been resolved in version 0.246.0 🎉
The release is available on:
Your semantic-release bot 📦🚀