You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thank you for your great work on AIStudio2API!
I use AIStudio2API heavily with OpenCode (intensive multi-step agentic coding sessions with tool calls).
On �0.3.5, I worked for 24 hours straight non-stop without a single bug: responses were clean, complete, high-quality, and tool calls worked reliably.
Right after upgrading to �0.3.6 (and the exact same logic remains in �0.3.7), responses started getting cut off / awkwardly stitched mid-stream, overall answer quality dropped noticeably, and strange internal delimiter characters (such as U+1290 U+1F4AD thought markers and duplicated text fragments) started leaking directly into the visible assistant text.
Rolling back to �0.3.5 immediately fixed everything — zero bugs again.
Root Cause Analysis in Code / 代码根因定位
Comparing �0.3.5 vs �0.3.6 / �0.3.7 in internal/aistudio/generate.go (introduced in PR #143 / commits d3c4801 and ef05bb0):
In �0.3.5 (internal/aistudio/generate.go):
egenerable(ctx, err, finish, committed) strictly required !committed. Once visible text had already been emitted to the client (committed == true), �0.3.5 never attempted to silently stitch a second generation on top of an already-streamed partial text response.
In �0.3.6 and �0.3.7 (internal/aistudio/generate.go, lines 963–1014 & 1176–1310):
When committed == true and committedTextOnly(output) is non-empty, the regeneration loop intercepts mid-stream failures (malformed_function_call, unexpected_tool_call, stream cutoffs) and silently sends a synthetic continuation request with:
RoleAssistant: emittedText
RoleUser: partialContinuationPrompt(emittedText, finish) (<partial_reply>...</partial_reply> Continue immediately right after <partial_reply> without repeating it...)
continuationPrefixStripper trying to strip repeated prefixes via exact string matching (strings.HasPrefix).
Why this breaks output quality and leaks strange symbols:
In the hidden second round, the model starts from a synthetic <partial_reply> prompt, altering its internal reasoning/thinking state (Thought) and reasoning depth mid-turn.
Internal thought delimiter tokens (U+1290 U+1F4AD) or malformed partial chunks leak into EventText.
Whenever the model slightly rephrases even one word or punctuation mark of the prefix in the continuation round, continuationPrefixStripper fails exact prefix matching and flushes s.pending into the live stream, resulting in truncated/garbled sentences and degraded response quality.
Request / 建议
Could you please remove this mid-stream partial text continuation (partialContinuationPrompt + continuationPrefixStripper when committed == true) and restore the rock-solid �0.3.5 behavior (!committed), or at least make it disabled by default behind an optional config flag?
it's my fault. I used opus to help merge the PR, even though I had already rejected this implementation in #92 (comment), so either way, it was caused by my stupidity. I'll delete it cleanly in the next version.
Activity
Mag1cFall commentedon Nov 13, 2026
it's my fault. I used opus to help merge the PR, even though I had already rejected this implementation in #92 (comment), so either way, it was caused by my stupidity. I'll delete it cleanly in the next version.