feat: bump supercode-cli version to 0.1.89 and improve error handling for usage limits:#231
Conversation
… for usage limits: - Updated version in package.json to 0.1.89. - Enhanced error responses in server-proxy-service.ts to provide clearer feedback when usage limits are reached, returning structured messages instead of generic errors.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
WalkthroughCredit-limit failures in ChangesCredit-limit response handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/supercode-cli/server/src/cli/ai/server-proxy-service.ts`:
- Around line 119-125: The usage accumulator in sendMessage() is reset to zero
when constructing the credit-limit response, discarding tokens from earlier
tool-call rounds. Preserve the existing accumulated usage values instead of
replacing them with a zeroed object, while retaining zero defaults only when no
prior usage exists so appendProxyUsage() records the full total.
- Around line 522-524: The credit-limit branch in the generator service returns
an object that does not conform to the generateObject schema. Update this branch
to use the contract’s established typed error/envelope or documented sentinel
shape, including any required discriminator, so callers can parse and surface
the limit response without schema validation failure.
- Around line 116-127: The credit-limit branch must emit its synthetic response
through onChunk because getMessage() derives its result exclusively from that
callback. Update the branch containing the “You've used your limits” response to
pass the response content to onChunk before returning, while preserving the
existing response object and metadata.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8fa53ca9-e7b6-4d9a-96ed-878a881e53d1
📒 Files selected for processing (2)
apps/supercode-cli/server/package.jsonapps/supercode-cli/server/src/cli/ai/server-proxy-service.ts
| return { | ||
| content: "You've used your limits. Resets in 24hrs.", | ||
| finishReason: "stop" as FinishReason, | ||
| usage: { | ||
| inputTokens: 0, | ||
| inputTokenDetails: { noCacheTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 }, | ||
| outputTokens: 0, | ||
| outputTokenDetails: { textTokens: 0, reasoningTokens: 0 }, | ||
| totalTokens: 0, | ||
| }, | ||
| toolCalls: [], | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Emit the synthetic response through onChunk.
getMessage() ignores the value returned by sendMessage() and builds its result exclusively from onChunk. Since this branch only returns content, credit-limit responses make getMessage() return an empty string.
Proposed fix
+ const message = "You've used your limits. Resets in 24hrs."
+ onChunk?.(message)
return {
- content: "You've used your limits. Resets in 24hrs.",
+ content: message,📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| return { | |
| content: "You've used your limits. Resets in 24hrs.", | |
| finishReason: "stop" as FinishReason, | |
| usage: { | |
| inputTokens: 0, | |
| inputTokenDetails: { noCacheTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 }, | |
| outputTokens: 0, | |
| outputTokenDetails: { textTokens: 0, reasoningTokens: 0 }, | |
| totalTokens: 0, | |
| }, | |
| toolCalls: [], | |
| } | |
| const message = "You've used your limits. Resets in 24hrs." | |
| onChunk?.(message) | |
| return { | |
| content: message, | |
| finishReason: "stop" as FinishReason, | |
| usage: { | |
| inputTokens: 0, | |
| inputTokenDetails: { noCacheTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 }, | |
| outputTokens: 0, | |
| outputTokenDetails: { textTokens: 0, reasoningTokens: 0 }, | |
| totalTokens: 0, | |
| }, | |
| toolCalls: [], | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/supercode-cli/server/src/cli/ai/server-proxy-service.ts` around lines
116 - 127, The credit-limit branch must emit its synthetic response through
onChunk because getMessage() derives its result exclusively from that callback.
Update the branch containing the “You've used your limits” response to pass the
response content to onChunk before returning, while preserving the existing
response object and metadata.
| usage: { | ||
| inputTokens: 0, | ||
| inputTokenDetails: { noCacheTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 }, | ||
| outputTokens: 0, | ||
| outputTokenDetails: { textTokens: 0, reasoningTokens: 0 }, | ||
| totalTokens: 0, | ||
| }, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Preserve usage from earlier tool-call rounds.
sendMessage() replaces its usage accumulator with this zeroed object. If the credit-limit response follows successful tool calls, the final totalTokens becomes 0, causing appendProxyUsage() to skip recording the earlier usage.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/supercode-cli/server/src/cli/ai/server-proxy-service.ts` around lines
119 - 125, The usage accumulator in sendMessage() is reset to zero when
constructing the credit-limit response, discarding tokens from earlier tool-call
rounds. Preserve the existing accumulated usage values instead of replacing them
with a zeroed object, while retaining zero defaults only when no prior usage
exists so appendProxyUsage() records the full total.
| return { | ||
| object: { message: "You've used your limits. Resets in 24hrs." }, | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -n -C4 '\bgenerateObject\s*\(' apps/supercode-cli/serverRepository: yashdev9274/supercli
Length of output: 5365
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== file outline =="
ast-grep outline apps/supercode-cli/server/src/cli/ai/server-proxy-service.ts --view compact || true
echo "== relevant implementation =="
sed -n '460,535p' apps/supercode-cli/server/src/cli/ai/server-proxy-service.ts
echo "== calls to generateObject or use of returned object =="
rg -n -C3 'generateObject|\.object|serverProxy|ServerProxyService|new .*Service' apps/supercode-cli/server/src || true
echo "== package dependencies mentioning schema/generation =="
fd -a 'package.json' apps/supercode-cli/server | xargs -r cat | rg -n '"(ai|`@ai-sdk`|generateObject|zod)"|(`@types`)?zod' || trueRepository: yashdev9274/supercli
Length of output: 35438
🌐 Web query:
vercel ai SDK generateObject return object shape schema zod
💡 Result:
The Vercel AI SDK's generateObject function generates a typed, structured object by enforcing a schema defined using Zod [1][2]. When calling generateObject, you pass your Zod schema to the schema parameter [1][3]. The function returns a result object containing the property object, which is a typed object that conforms to the shape defined by your Zod schema [1][4]. Key details include: - Schema Usage: You provide a Zod object (e.g., z.object({...})) to the schema property. The AI SDK uses this to validate the generated data at runtime, ensuring type safety [1][3]. - Output Strategies: While the default output is a single object, you can change the output strategy to 'array' if you want the model to return an array of items matching your schema [1][2]. - Integration: The returned object is automatically typed based on the Zod schema provided, allowing for full TypeScript support in your application [1][3]. - Convenience Methods: The result also includes helper methods like toJsonResponse(), which converts the generated object into a JSON response suitable for web frameworks [1][4]. Example Usage: import { generateObject } from 'ai'; import { z } from 'zod'; const { object } = await generateObject({ model: yourModel, schema: z.object({ name: z.string, age: z.number, }), prompt: 'Generate a person profile.', }); // 'object' is typed as { name: string; age: number; } console.log(object.name);
Citations:
- 1: https://ai-sdk.dev/v5/docs/reference/ai-sdk-core/generate-object
- 2: https://vercel-ai.mintlify.app/reference/ai-sdk-core/generate-object
- 3: https://ai-sdk.dev/v5/docs/ai-sdk-core/generating-structured-data
- 4: https://ai-sdk.dev/v4/docs/reference/ai-sdk-core/generate-object
Handle the credit-limit sentinel in the generator contract.
generateObject() is meant to return result.objects conforming to the input schema, but this branch returns { object: { message } } with no discriminator. Since ai validates structured generation against the schema, callers can fail to parse a credit-limit response that should be surfaced as a typed error/envelope or a documented sentinel shape.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/supercode-cli/server/src/cli/ai/server-proxy-service.ts` around lines
522 - 524, The credit-limit branch in the generator service returns an object
that does not conform to the generateObject schema. Update this branch to use
the contract’s established typed error/envelope or documented sentinel shape,
including any required discriminator, so callers can parse and surface the limit
response without schema validation failure.
Description
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
bun testpassesbun run typecheckpassesbun run lintpasses (if applicable)Checklist:
Summary by CodeRabbit