Skip to content

[AI-4057] Say plainly what each streamed-answer limit is for - #2627

Merged
kanat merged 2 commits into
mainfrom
fix/ai-4057-limit-comments
Nov 28, 2026
Merged

kanat merged 2 commits into
mainfrom
fix/ai-4057-limit-comments

Conversation

@kanat

@kanat kanat commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Why

The code comments that #2597 added for the streamed-answer limits were hard to follow when read cold. This PR rewrites nine of them in plain sentences. No code changes.

Changes

Comment What it explains now
maxAnswerBytes what the answer limit counts, and why the bytes-a-token figure is that high
maxStreamBytes the body limit is the answer limit plus the JSON around each piece of text
chunkBytes the least each choice and tool call fragment counts toward the limit, and why
maxEventBytes why one event never needs more than the answer limit
maxEventValues why values are counted as well as bytes, and what is not counted
callBytes what each new tool call counts on top of its text
eventLimit when an event ends and how the failure matches http.MaxBytesReader
line feed check in eventLimit.Read the event is checked before it is reset, and the line feed is not passed on
string copy in Advance why the text the response keeps is cloned

Validation

The diff only touches comments in acceleration/internal/llm/openaicompat/openaicompat.go. The build, go vet and the package tests pass.

Commands
cd acceleration && go build ./... && go vet ./internal/llm/openaicompat/ && go test ./internal/llm/openaicompat/
git diff origin/main --stat   # openaicompat.go only

The wording of each comment comes from the text review of #2597.

🤖 Generated with Claude Code

The comments added with the streamed-answer limits were hard to follow on a
cold read. This rewrites nine of them. No code changes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: NO-GO. The nine rewrites are applied word for word, and eight of them are true to the code beside them. The one on maxStreamBytes gives a wrong example.

T1.1 (prior, comments): open. Eight comments check out. The maxStreamBytes comment needs the change in the inline comment.

D1 (new, inline): one wrong example. The maxStreamBytes comment says the body limit stops an event whose data lines never end. eventLimit stops that event at maxEventBytes, long before the body limit is reached. The body limit stops blank lines and data-less events that Advance never sees.

Checks

  • git diff c55ad4210 985af0181: 32 lines changed in openaicompat.go, all comments.
  • gofmt -l: clean. go build ./... and go vet ./internal/llm/openaicompat/: pass. go test ./internal/llm/openaicompat/: pass.
  • Head is unchanged at 985af0181.

…ess event

The comment said the body limit stops one event whose data lines never end.
eventLimit cuts that event at maxEventBytes, well before the body limit.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: GO

Delta review of the D1 fix at 2894a1f (was 985af01). The change is one comment in acceleration/internal/llm/openaicompat/openaicompat.go, and nothing else in the diff.

  • The new last sentence matches the code. The body cap is set in sniff (the http.MaxBytesReader call with maxStreamBytes), and eventLimit cuts an event that runs on without a blank line well before that cap.
  • eventLimit resets its counters at each blank line, so a stream of blank lines reaches only the body cap. The comment says so.
  • The comment is the replacement text suggested in the review thread, word for word. Build, vet and gofmt pass. The package tests pass on the new head.
  • Comment-only change, so no mutation applies. The claims were checked by reading the code.

D1 is fixed, and its thread is resolved. No new findings.

@kanat
kanat marked this pull request as ready for review November 27, 2026 03:40
@kanat
kanat merged commit 2cee641 into main Nov 28, 2026
20 of 21 checks passed
@kanat
kanat deleted the fix/ai-4057-limit-comments branch November 28, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant