fix: maxTokens not used
Description
maxOutputTokens set but never used
Type of Change
- [x] Bug fix
- [ ] New feature
- [ ] Documentation
- [ ] Refactor
- [ ] Other (please describe):
[!IMPORTANT] Fix missing
maxOutputTokensparameter instreamTextcall increateRootAgentStreaminroot.ts.
- Bug Fix:
- Add
maxOutputTokens: modelConfig.maxOutputTokenstostreamTextcall increateRootAgentStreaminroot.tsto ensure token limit is applied.This description was created by
for 7e42a077c3241fe4ddb050b472e68afd84b8c0bd. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit
-
New Features
- Added configurable maximum output length for AI responses so streamed replies respect the selected model’s cap, improving predictability and cost control.
-
Bug Fixes / UX
- Tool actions invoked from chat now complete before subsequent UI updates, improving error reporting and making state updates and message ordering more predictable.
@dingdinglz is attempting to deploy a commit to the Onlook Team on Vercel.
A member of the Team first needs to authorize it.
Walkthrough
Adds a maxOutputTokens argument to the root stream call and changes a chat tool-call handler from fire-and-forget to awaiting the tool call completion, altering execution ordering and error propagation.
Changes
| Cohort / File(s) | Summary |
|---|---|
Root agent streaming configpackages/ai/src/agents/root.ts |
Passes maxOutputTokens (from modelConfig.maxOutputTokens) into streamText within createRootAgentStream. |
Chat tool-call handlingapps/web/client/src/app/project/[id]/_hooks/use-chat/index.tsx |
Replaces a non-blocking void fire-and-forget tool invocation with an awaited call in onToolCall, making the handler wait for completion before continuing and preserving the subsequent state-reset logic. |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant Caller
participant RootAgent
participant TextStreamer as streamText
Caller->>RootAgent: createRootAgentStream(modelConfig)
Note right of RootAgent: reads modelConfig.maxOutputTokens
RootAgent->>TextStreamer: streamText({... , maxOutputTokens})
TextStreamer-->>RootAgent: Streamed text chunks
RootAgent-->>Caller: Forward streamed output
sequenceDiagram
autonumber
participant UI
participant useChatHook as Hook
participant Tool
UI->>Hook: onToolCall(params)
Note right of Hook #DDEBF7: previously used `void Tool.call()` (fire-and-forget)
Hook->>Tool: await Tool.call(params)
Tool-->>Hook: result / error
Hook-->>UI: update isExecutingToolCall = false (after completion)
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- onlook-dev/onlook#2953 — Adjusts createRootAgentStream to pass
modelConfig.maxOutputTokensinto streaming and also makes related use-chat tool calls synchronous; strongly related to the root streaming and tool-call flow changes. - onlook-dev/onlook#2846 — Changes chat
onToolCallbehavior (fire-and-forget vs awaited), directly related to the synchronous tool-call adjustment in this diff.
Poem
I nibble code and count the hops,
Tokens tucked in tidy crops.
I wait a beat for tools to say,
Then scamper on my streaming way.
A little hop, a tidy stream—🐇
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title Check | ✅ Passed | The pull request title "fix: maxTokens not used" directly and accurately summarizes the main change in the pull request. The raw summary confirms that maxOutputTokens was added to the streamText call in createRootAgentStream, which aligns perfectly with the stated problem that "maxTokens [was] not used." The title is concise, clear, and specific enough for a teammate to understand the core fix from the commit history. |
| Description Check | ✅ Passed | The pull request description provides a concise explanation of the bug ("maxOutputTokens set but never used") and correctly identifies the Type of Change as a bug fix. While the description is minimal and omits some template sections like Related Issues, Testing, and Additional Notes, it clearly communicates the core issue and solution without being vague or off-topic. For a straightforward bug fix of this scope, the provided information is sufficient to understand the change, and the missing sections may be non-critical in this context. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.