[Feature] Accept an m suffix in --context-max and /context-max (1m)
Description
--context-max and /context-max accept k as a suffix (128k) but not m, so --context-max 1m is rejected even though 1M-token context windows are now common.
Use Case
Many current models have 1M token windows. Typing 1000k works, but 1m is the obvious thing to write, and the error does not hint at the workaround.
Proposed Solution
Accept an m / M suffix (multiplier 1,000,000) in parseContextLimit. All three callers (cli.tsx, the /context-max handler and the inline overrides) share that one function, so the change is in one place. Update the two error messages that say e.g. 8192 or 128k to mention 1m as well.
While in there: a bare decimal such as 1.5 is currently accepted and rounded to 2, which is almost certainly a typo for 1.5k. Rejecting fractional values without a suffix would be safer.
Alternatives Considered
Leave it and document 1000k. It is a tiny change though, and the current failure is a confusing "Use a positive number" message for something that looks like a positive number.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] This feature aligns with the project's goals (local-first AI assistance)
Implementation Notes (optional)
Current behaviour of parseContextLimit on a few inputs: 128k -> 128000, 1m -> null, 1M -> null, 1.5 -> 2, 9999999999999999999999 -> 1e+22 (accepted). An upper sanity bound would be reasonable too, since the value is stored without further checks.
Hi maintainers! I'd like to work on this issue.
I've reviewed the requirements and would be happy to implement support for both m and M suffixes, update the validation/error messages, and add the necessary regression tests.
I also noticed that the existing tests allow bare decimal values (e.g. 1024.5). Should this behavior remain backward-compatible, or should bare decimals be rejected as mentioned in the issue?
Thanks!
Hi @KunjMaheshwari, thanks for your work on this! Going forward, please comment on an issue first and wait to be assigned before you start working on it. That way we avoid duplicate work and keep things fair for everyone.
Thanks for contributing!