fix(cli): UnboundLocalError for ctx_len in compact banner path#4385
Closed
luqs1 wants to merge 1 commit intoNousResearch:mainfrom
Closed
fix(cli): UnboundLocalError for ctx_len in compact banner path#4385luqs1 wants to merge 1 commit intoNousResearch:mainfrom
luqs1 wants to merge 1 commit intoNousResearch:mainfrom
Conversation
ctx_len was only initialized inside the full-banner else branch but referenced unconditionally afterwards, crashing the CLI when the terminal is narrower than 80 columns. Move the initialization before the if/else so both paths have access. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thanks for catching this bug! I independently discovered the same issue and had already applied the fix locally. My PR #4392 was a duplicate - I've closed it. This fix is definitely needed - it crashes when using compact banner mode (narrow terminal or --compact flag). Great catch! |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ctx_lenwas only initialized inside the full-bannerelsebranch but referenced unconditionally on line 2201, causingUnboundLocalErrorwhen the terminal is narrower than 80 columns (compact banner path).if/elseso both paths have access.Repro
hermesUnboundLocalError: cannot access local variable 'ctx_len'Test plan
hermesin a terminal < 80 cols wide — no crashhermesin a terminal >= 80 cols wide — banner displays normally with context length warning if applicable🤖 Generated with Claude Code