Skip to content

Allow context window env override for all builds#31

Open
elliothux wants to merge 2 commits intopaoloanzn:mainfrom
elliothux:codex/context-window-env-override
Open

Allow context window env override for all builds#31
elliothux wants to merge 2 commits intopaoloanzn:mainfrom
elliothux:codex/context-window-env-override

Conversation

@elliothux
Copy link
Copy Markdown

@elliothux elliothux commented Apr 16, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Removed user-type restriction on environment-based context token override so configured token limits apply for all users.
    • Improved streaming error reporting for exceeded model context: responses now include a clear, machine-friendly overflow indicator to aid recovery and routing.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a754659c-d212-45c8-8cfd-2dca7de5d5af

📥 Commits

Reviewing files that changed from the base of the PR and between 01b17eb and 6531db9.

📒 Files selected for processing (1)
  • src/services/api/claude.ts

📝 Walkthrough

Walkthrough

The CLAUDE context-window override CLAUDE_CODE_MAX_CONTEXT_TOKENS now applies to all user types when set to a valid positive integer. Streaming handling for stopReason === 'model_context_window_exceeded' now yields an assistant error including errorDetails: 'context_window_exceeded' alongside the existing max-output error fields.

Changes

Cohort / File(s) Summary
Context Window Configuration
src/utils/context.ts
Removed the process.env.USER_TYPE === 'ant' gate so CLAUDE_CODE_MAX_CONTEXT_TOKENS override applies universally when parsed as a positive integer.
Streaming Error Handling
src/services/api/claude.ts
When streaming stops with model_context_window_exceeded, the yielded assistant error now includes errorDetails: 'context_window_exceeded' in addition to existing max-output error fields for clearer routing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰🌱 I hopped through code to clear the gate,
A token window opened wide and late.
Streams now label why they cease,
A tidy hop toward calmer peace.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: removing the USER_TYPE === 'ant' gate to allow the CLAUDE_CODE_MAX_CONTEXT_TOKENS environment override to apply to all user types/builds.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Updated the error message structure to maintain consistency with the max_output_tokens error shape, ensuring existing clients experience the same user experience. Added detailed overflow information for improved recovery routing.
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