th-9a5794: fast-model preamble to cover reasoning-model time-to-first-token#81
Open
brentrager wants to merge 1 commit into
Open
th-9a5794: fast-model preamble to cover reasoning-model time-to-first-token#81brentrager wants to merge 1 commit into
brentrager wants to merge 1 commit into
Conversation
…-first-token The gpt-oss-120b operator brain feels slow not from throughput (Groq is sub-second p95) but from latency-to-first-token: a reasoning model behind the llm.smoo.ai gateway sits on dead air while it reasons + resolves its first tool call. The gateway only exposes reasoning_content + content/tool_calls (no clean harmony preamble channel), so the raw thought is unshowable. This adds an optional, off-by-default parallel "preamble": when AgentConfig.preamble is set, run_with_channel fires a small fast model (e.g. groq-gpt-oss-20b) concurrently with the main model's first turn and streams ONE short present-tense "what I'm about to do" sentence as a new additive AgentEvent::PreambleDelta — an ephemeral status line the real answer replaces. It's best-effort: any error/slowness is swallowed so it can never block or break the turn. Lives in the Rust core so every SmooAI brain (chat-ws, voice, HeyPage, general-agent→Rust) inherits it with no per-service copy and no new TypeScript. Off unless configured — every existing consumer is byte-for-byte unaffected. 546 lib tests pass; 2 new tests cover the emit path and the off-by-default no-op. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WEUZgsyfGVab8uqSFPbr23
|
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.
Problem
The
gpt-oss-120boperator brain feels slow — but not from throughput (Groq is sub-second p95). It's latency-to-first-token: a reasoning model behind thellm.smoo.aigateway sits on dead air while it reasons and resolves its first tool call. The gateway only surfacesreasoning_content+content/tool_calls— there's no clean harmony preamble channel — so the raw thought is unshowable.Solution
An optional, off-by-default parallel preamble. When
AgentConfig.preambleis set,run_with_channelfires a small fast model (e.g.groq-gpt-oss-20b) concurrently with the main model's first turn and streams ONE short present-tense "what I'm about to do" sentence as a new additiveAgentEvent::PreambleDelta— an ephemeral status line the real answer replaces.AgentEvent→ older consumers skip the unknown variant (no preamble shown), everything else unchanged.preamble.modelsharing the main gateway/key; tests route through the injected mock (hermetic).Scope / what's NOT here yet
This is the reusable core slice only. To actually turn it on end-to-end (follow-ups):
preamble/statuswire event so the widget renders it distinctly (ephemeral, replaced) vs. permanent chat content.AgentConfig.preamble(gated by a flag/config key) + crate version bump +core-v*publish.Known limitation for the wiring phase: the preamble fires on every turn, so a rare instant (no-reasoning) follow-up could show it briefly before the answer replaces it. A "only if first token hasn't arrived within Nms" gate is a cheap future refinement — deliberately not built yet.
// ponytail:Rust reference impl only; the TS/Go/.NET/Python core ports skip this until a non-Rust consumer needs it.Tests
preamble_emits_delta_and_does_not_break_the_turn— asserts thePreambleDeltafires AND the real answer still lands.preamble_off_by_default_emits_nothing— no preamble config → zero extra LLM calls, no event.checkpoint.rs).🤖 Generated with Claude Code
https://claude.ai/code/session_01WEUZgsyfGVab8uqSFPbr23