Skip to content

fix(cli): UnboundLocalError for ctx_len in compact banner path - #4385

Closed
luqs1 wants to merge 1 commit into
NousResearch:mainfrom
luqs1:fix/ctx-len-unbound-error
Closed

fix(cli): UnboundLocalError for ctx_len in compact banner path#4385
luqs1 wants to merge 1 commit into
NousResearch:mainfrom
luqs1:fix/ctx-len-unbound-error

Conversation

@luqs1

@luqs1 luqs1 commented Apr 1, 2026

Copy link
Copy Markdown

Summary

  • ctx_len was only initialized inside the full-banner else branch but referenced unconditionally on line 2201, causing UnboundLocalError when the terminal is narrower than 80 columns (compact banner path).
  • Moves initialization before the if/else so both paths have access.

Repro

  1. Resize terminal to < 80 columns
  2. Run hermes
  3. Crash: UnboundLocalError: cannot access local variable 'ctx_len'

Test plan

  • Run hermes in a terminal < 80 cols wide — no crash
  • Run hermes in a terminal >= 80 cols wide — banner displays normally with context length warning if applicable

🤖 Generated with Claude Code

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>
@andyg5000-agent

Copy link
Copy Markdown

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!

@teknium1

teknium1 commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Fixed in PR #4411, which cherry-picked the implementation from #4334 (first submitted, moved both init and lookup). Thanks for the report @luqs1!

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.

3 participants