feat: per-model compaction thresholds, configurable effort ladders, and JCODE_SHOW_BASH_OUTPUT env override
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 19.9k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 30
Description
Three changes are ready on a branch, rebased onto current master (a63dbc45). I could not open a pull request — createPullRequest returns a permissions error for this repo — so I am filing this instead. Happy to open a PR if external PRs get enabled, or feel free to cherry-pick directly.
Branch: https://github.com/davidfarah2003/jcode/tree/feat/compaction-thresholds-and-effort-ladders
Compare: https://github.com/1jehuang/jcode/compare/master...davidfarah2003:jcode:feat/compaction-thresholds-and-effort-ladders
Each commit builds on its own, so git bisect stays usable, and each is independently useful if you only want one of them.
1. JCODE_SHOW_BASH_OUTPUT cannot be overridden (bc95c7fc)
One line. The variable is read in env_overrides.rs:295 but is missing from CONFIG_ENV_KEYS in config.rs, so setting it has no effect.
This repo already has a test for exactly this: config::tests::config_env_fingerprint_tracks_every_apply_env_override_var asserts every variable read by apply_env_override is listed in CONFIG_ENV_KEYS. It is currently red on master and goes green with this commit. Worth taking on its own regardless of the other two.
2. Reasoning effort ladders are not configurable (a83272ac)
Three related bugs when a non-OpenAI model is served through an OpenAI-compatible provider:
inferred_reasoning_effortsonly recognizesgpt-*, so any other model behind that provider gets no effort ladder.remote_reasoning_effort_hintmatchesprovider.contains("openai"), which is also true foropenai-compatible:<name>. A global default then leaks in and renders as a phantom "Effort: Low" on models that never advertised an effort ladder.- The openrouter runtime rejects
set_reasoning_effortfor non-gpt-*ids, so even a correct ladder cannot be applied.
Adds a reasoning_efforts field to NamedProviderModelConfig so a provider entry can declare the ladder its models actually support, with the existing family heuristics kept as the fallback when nothing is configured. Reasoning effort stays a request parameter, not a separate model id.
3. No way to compact below the context-relative trigger (96bda36d)
Auto-compaction fires at a fixed fraction of the context window. On a 1M-context model that is ~840k tokens — well past where quality degrades and a turn gets expensive — and there is no way to say "compact at 200k regardless of window size".
Adds /compact-at:
/compact-at # show the active threshold and where it came from
/compact-at 200k # compact this model at 200k tokens
/compact-at off # disable the absolute trigger for this model
Precedence is per-model entry > config default > existing context-relative behavior. An explicit off (stored as 0) beats the default, so one model can opt out while the default still governs the rest.
[compaction]
default_threshold_tokens = 500000
[compaction.per_model_threshold_tokens]
"some-model" = 200000
"other-model" = 0 # off, even though a default exists
Notes:
- The absolute trigger is additive: it does not change the real context window or the percentage trigger, it just fires first when it is lower.
- Thresholds are keyed by bare model id. The runtime model string can transiently carry a
<profile>:<model>prefix right after session restore, so the lookup falls back to the segment after the first:— the same defensive shapecontext_window()already uses. - Effective token count is
max(estimate, observed_input_tokens), so a threshold tracks what the provider actually billed, not just the local estimate. - Works in local and remote/server mode; new
SetCompactionThreshold/CompactionThresholdChangedprotocol messages carry it.
Testing
cargo build --workspaceclean; each commit builds standalone.cargo test -p jcode-base --lib compaction— 39 pass, covering per-model entries, the config default, explicit-off precedence, and the profile-prefix fallback.- New threshold tests take an explicit config instead of reading the developer's live
~/.jcode/config.toml(awith_compaction_configconstructor was added for that;new()is unchanged). The first version of these tests passed or failed depending on the machine's real config, which seemed worth avoiding. - No regressions.
cargo test -p jcode-base --libon the same machine: 19 failures on a cleanv0.78.1checkout, 15 on this branch. Every failure here also fails on an unmodified tree — they look environment-dependent (auth, browser paths, platform spawn, skills). The four that go green include theCONFIG_ENV_KEYSguard above. - Verified end to end on a real session: with a 30k threshold, compaction fired at effective 30028 tokens, summarized 6 messages, 30061 → 18242 tokens, and the session continued normally.
- Built and exercised on macOS (aarch64) and Linux (x86_64).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the three commits on the feat/compaction-thresholds-and-effort-ladders branch, starting with env_overrides.rs:295, config.rs, and the named CONFIG_ENV_KEYS test. Run cargo build --workspace and the listed compaction and jcode-base library tests; done means the three changes build independently and the stated threshold, effort-ladder, and environment-override tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100