Skip to content

Routed models' comp_hash inherits from whichever native row is catalog-first, forcing unrelated compaction on every routed thread #5796

Closed

Description

@c040340

Client or integration

Codex App

Area

Catalog / models

Summary

Routed catalog rows (any provider/model slug — local bridges, OpenRouter, DeepSeek, etc.) inherit comp_hash from whichever native GPT row findSupportedNativeTemplate() happens to pick as the clone template (src/codex/catalog/derive-entry.ts:124-146, cloning src/codex/catalog/parsing.ts:363-372's pick). Which native row that is can change between two catalog rewrites that are otherwise unrelated to the routed models themselves, because different rebuild paths read different source catalogs (current catalog vs. catalog backup vs. active Codex models cache vs. bundled — the fallback chain in src/codex/catalog/bundled.ts:540-551).

comp_hash is not stripped for routed rows the way context_window/max_context_window/auto_compact_token_limit already are (derive-entry.ts:139-145, with the comment "A routed model is NOT the native template: never inherit its context window..."), so it survives the clone as an accident of catalog rebuild order rather than a real property of the routed model.

Per openai/codex#27520, Codex compacts a thread before its next turn whenever the thread's recorded model comp_hash no longer matches the current one. So every unrelated catalog rewrite that happens to change which native row is template-eligible silently force-compacts every active routed thread on its next turn — regardless of how full the context actually is, and with no log line or catalog diff warning the user beforehand. It can also flip back and forth (observed 3000 → opencodex → 3000 within ~8 hours), so a thread can pay the compaction cost twice for no reason related to its own model or usage.

Expected: a routed model's comp_hash should be a stable, deterministic property of that model (e.g. derived from provider name + model id + adapter), not inherited from whichever unrelated native row happens to be catalog-first on a given rebuild.

Reproduction

This is intermittent and depends on catalog rebuild history rather than a fixed command sequence, but the trigger is reliable:

  1. Have at least one routed provider registered (e.g. via connect-local-bridges.cjs, or any custom provider) and an active Codex thread using a routed model.
  2. Trigger a catalog rebuild through a path whose findSupportedNativeTemplate() resolves to a different native row than the previous rebuild did — e.g.:
    • registering/re-registering a provider (calls into the catalog builder), or
    • an OpenCodex resync/restart that reads a different source catalog (current vs. backup vs. active-models-cache vs. bundled) than the last rebuild, especially if a catalog backup was recovered that predates the comp_hash field (falls through to the "opencodex" default at parsing.ts:634).
  3. Diff ~/.codex/opencodex-catalog.json before/after: every routed row's comp_hash changes together, in lockstep, even though no routed model itself changed.
  4. Send the next message on any routed-model thread that had a prior turn recorded with the old comp_hash. Codex compacts before answering, even at low context fill.

Observed concretely on 2026-09-24 (times local):

time trigger routed comp_hash
through 03:53 (baseline, many prior rebuilds) "3000"
03:53:18 connect-local-bridges.cjs registered a new provider (routine add, unrelated to any native model) "3000" → "opencodex" — template became gpt-5.5, restored from an old catalog backup with no comp_hash, defaulted per parsing.ts:634
06:48:19 opencodex restart / pinned-start resync stayed "opencodex"
11:59:06 a user action inside the OpenCodex dashboard (package still 2.64.0, no process restart) rewrote ~/.opencodex/config.json —
12:01:34 catalog rewritten again; template resolved back to a "3000"-tagged native row "opencodex" → "3000"

Every routed thread with a turn recorded between 03:53 and 12:01 (comp_hash:"opencodex") compacted on its next message after 12:01 — at context fills of 12%, 16%, 24%, 24%, and 30% of the model's auto_compact_token_limit (896,800 tokens for the affected model), nowhere near the normal 95% compaction threshold. None of these threads' routed model changed in any way — same provider, same model id, same context window; only the unrelated native template row changed.

Version

2.64.0

Operating system

Windows 11 Pro, 10.0.26200 (Build 26200)

Provider and model

Not provider-specific — reproduced across every routed provider active at the time (local bridge providers and openai-1m/gpt-6-sol). Affects any routed (namespaced provider/model) catalog row.

Logs or error output

Session comp_hash trace (routed threads), local time:
2026-09-24T11:14:37Z  3000->opencodex   openai-1m/gpt-6-sol
2026-09-24T11:37:59Z  3000->opencodex   openai-1m/gpt-6-sol
2026-09-24T16:09:21Z  3000->opencodex   local-zcode/glm-5.3-flash
2026-09-24T19:03:26Z  opencodex->3000   local-zcode/glm-5.3-flash
2026-09-24T19:03:49Z  opencodex->3000   local-zcode/glm-5.3-flash
2026-09-24T19:03:59Z  opencodex->3000   local-zcode/glm-5.3-flash
2026-09-24T19:04:27Z  opencodex->3000   local-zcode/glm-5.3-flash
2026-09-24T19:04:32Z  opencodex->3000   openai-1m/gpt-6-sol
2026-09-24T19:04:34Z  opencodex->3000   local-zcode/glm-5.3-flash
2026-09-24T19:07:08Z  opencodex->3000   openai-1m/gpt-6-sol

Context fill at compaction (well below the 95% auto_compact_token_limit gate):
2026-09-24T10:57Z  fill=16%  (146041 / 896800 tokens)
2026-09-24T10:58Z  fill=24%  (218981 / 896800 tokens)
2026-09-24T10:58Z  fill=12%  (111901 / 896800 tokens)
2026-09-24T11:02Z  fill=30%  (267585 / 896800 tokens)
2026-09-24T11:07Z  fill=24%  (213003 / 896800 tokens)

Screenshots and supporting files

None attached; happy to provide the full opencodex-catalog.json diff across the 03:53/12:01 rebuilds if useful.

Redacted configuration

Not config-dependent in a way a snippet would show — this reproduces with any routed provider registered, using the default catalog rebuild paths (no custom routing config involved).

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

  1. added
    catalog
    on Sep 24, 2026
  2. github-actions commented on Sep 24, 2026

    @github-actions
    Contributor

    Issue reopened

    The report now contains the information required by the automated check. Thanks for updating it.

  3. added
    bug
    on Sep 24, 2026
  4. added a commit that references this issue on Sep 25, 2026
    c0599d0
  5. lidge-jun commented on Sep 25, 2026

    @lidge-jun
    Owner

    Fixed on dev by #5802 (merge commit c0599d0). Routed catalog rows no longer inherit comp_hash from whichever native row a rebuild picked as its template. Every routed row gets the fixed "opencodex" marker, including rows kept from disk during a provider outage, so a catalog rebuild no longer forces compaction on active routed threads. Native, Codex-forward and foreign rows keep their own values. The fix ships in the next release. After updating, run ocx sync once to rewrite the catalog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcatalog

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions