Skip to content

fix(blackbox): single global fixed char->token divisor 4.2 -> 4.5 - #46

Merged
Kyzcreig merged 1 commit into
mainfrom
fix/fixed-divisor-4.5
Jun 15, 2026
Merged

Kyzcreig merged 1 commit into
mainfrom
fix/fixed-divisor-4.5

Conversation

@Kyzcreig

Copy link
Copy Markdown
Collaborator

Per Ace: use ONE divisor for both gateways (consistency), bump fixed 4.2->4.5 for a better system-prompt estimate; non-fixed stays 3.5.

Why 4.5: live post-deploy density measurement — Apollo/default ~4.36 ch/tok, Aegis ~4.83. 4.5 is the first single divisor landing BOTH inside the [0.90,1.05] acceptance band: Apollo 4.5/4.36=1.03 (3% under, safe), Aegis 4.5/4.83=0.93 (7% over, safe). 4.2 left Aegis at ~0.87 (just under band).

Constant + rationale comment + default-fallback test updated. 28/28 composition tests pass.

One divisor for ALL gateways (consistency over per-host tuning). Live
post-deploy density measurement: Apollo ~4.36 ch/tok, Aegis ~4.83. 4.5 is
the first single value that lands BOTH inside [0.90,1.05]: Apollo 1.03,
Aegis 0.93. 4.2 left Aegis at ~0.87 (just under band). Non-fixed stays 3.5.
@github-actions

Copy link
Copy Markdown

🔎 Lint report: fix/fixed-divisor-4.5 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9932 on HEAD, 9932 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5134 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@greptile-apps

greptile-apps Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

Greptile Summary

Bumps the default fixed char→token divisor from 4.2 to 4.5 (COMPOSITION_CHARS_PER_TOKEN_FIXED) and updates the rationale comment and test assertions to match. The change is grounded in live post-deploy density measurements showing 4.5 brings both the Apollo (~4.36 ch/tok) and Aegis (~4.83 ch/tok) gateways inside the [0.90, 1.05] acceptance band, where 4.2 left Aegis at ~0.87 (below band).

  • agent/model_metadata.py: Default return value changed from 4.2 to 4.5; surrounding comment rewritten with per-gateway acceptance-band math and "one global divisor by fiat" policy note.
  • tests/test_request_composition.py: test_fixed_divisor_default_and_out_of_range_fallback assertions updated from 4.2 to 4.5; two inline comments in sibling tests (~4.2 section header and # ~1690 at 4.2 annotation) were not updated and are now stale.

Confidence Score: 4/5

Safe to merge — the core constant change is correct and well-tested; two stale inline comments in the test file are the only loose ends.

The production change is a single numeric constant update with sound empirical backing and a clamp/env-override path that is untouched. The test logic is correct (it reads mm.COMPOSITION_CHARS_PER_TOKEN_FIXED rather than a hardcoded literal). Two inline comments in the test file still cite the old 4.2 value — a minor inconsistency but not a correctness risk.

tests/test_request_composition.py — two inline comments (line 248 section header and line 296 per-line annotation) still reference the old 4.2 divisor and should be updated.

Important Files Changed

Filename Overview
agent/model_metadata.py Default fixed char→token divisor bumped from 4.2 to 4.5; comment updated with live measurement data and acceptance-band rationale. Logic is correct and clamp/env-override path is unchanged.
tests/test_request_composition.py Default-value assertion and fallback-loop assertion updated from 4.2 to 4.5. Two inline comments (section header and per-line annotation) still reference the old 4.2 value and were missed in the sweep.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["_composition_chars_per_token_fixed()"] --> B{"HERMES_COMPOSITION_CHARS_PER_TOKEN_FIXED set?"}
    B -- Yes --> C{"2.0 ≤ val ≤ 8.0?"}
    C -- Yes --> D["Return env value"]
    C -- No --> E["Return 4.5 (default)"]
    B -- No --> E
    E --> F["COMPOSITION_CHARS_PER_TOKEN_FIXED = 4.5"]
    F --> G["Fixed buckets: sys_tokens, tool_schema_tokens\n÷ 4.5 (was 4.2)"]
    F --> H["Non-fixed buckets: history, tool_args, tool_result\n÷ 3.5 (unchanged)"]
Loading

Comments Outside Diff (2)

  1. tests/test_request_composition.py, line 248 (link)

    P2 The section header comment still references the old divisor value ~4.2; it should reflect the new default of 4.5 to stay consistent with the constant change.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  2. tests/test_request_composition.py, line 296 (link)

    P2 The inline annotation still reads # ~1690 at 4.2. With the new default of 4.5, math.ceil(7100 / 4.5) is 1578, so the comment is stale and could mislead anyone debugging the bound check.

Reviews (1): Last reviewed commit: "fix(blackbox): single global fixed char-..." | Re-trigger Greptile

@Kyzcreig
Kyzcreig merged commit 70c48d8 into main Jun 15, 2026
24 of 25 checks passed
@Kyzcreig
Kyzcreig deleted the fix/fixed-divisor-4.5 branch June 15, 2026 07:50
@Kyzcreig
Kyzcreig restored the fix/fixed-divisor-4.5 branch September 21, 2026 10:32
Kyzcreig pushed a commit that referenced this pull request Sep 28, 2026
…on thread (C5 #46)

Ruling: no notify spool/outbox exists in-tree, so page_once dispatches the
flock + notify send onto a tracked NON-daemon thread; flush_pages() gives it a
bounded 5 s join at exit (threading._register_atexit, before the interpreter's
non-daemon join) and logs any page still in flight. The dedup flock wait is
bounded (5 s, then the in-process dedup fallback) so the thread is self-bounded.
Test red on base (verdict blocked 10.16 s behind a slow page); shell_hooks +
shell_hooks_missing 110/110.
Kyzcreig pushed a commit that referenced this pull request Sep 28, 2026
…on thread (C5 #46)

Ruling: no notify spool/outbox exists in-tree, so page_once dispatches the
flock + notify send onto a tracked NON-daemon thread; flush_pages() gives it a
bounded 5 s join at exit (threading._register_atexit, before the interpreter's
non-daemon join) and logs any page still in flight. The dedup flock wait is
bounded (5 s, then the in-process dedup fallback) so the thread is self-bounded.
Test red on base (verdict blocked 10.16 s behind a slow page); shell_hooks +
shell_hooks_missing 110/110.
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