Skip to content

feat(config): named cache strategies in the proxy config - #987

Merged
amiddavid merged 3 commits into
mainfrom
feat/strategy-in-proxy
Nov 9, 2026
Merged

amiddavid merged 3 commits into
mainfrom
feat/strategy-in-proxy

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

No behavior change for any proxy.yaml without cache.strategy: it loads to the same config as before. The new code returns at once when strategy is empty. A test pins this.

One change to name: context-guru-proxy strategies used to start the proxy, because flag parsing stopped at the first positional argument. It now prints the table and exits. This is the same shape as import-history. Nobody uses it to start the proxy. Who it affects: no one known. To turn it off: not possible, the subcommand is fixed.

Data dependence: this PR documents existing strategies. It does not change any feature's data dependence. The rows are in docs/data-dependence.md.

  • none: works at all three levels. Keeps nothing.
  • auto (alias 5-min-ping), 1-ping, 2-ping, 30-min-ping: need stored request bytes (a ping sends the last request again). Off and metadata only: cannot work. Everything: works.
  • 1-hour-head: works at all levels. Sends no request of its own and keeps nothing.
  • cache.strategy itself only fills config keys. It stores nothing.

Summary

  • The proxy now owns the named cache strategy table.
  • Names: none, auto (default in the plugin), 1-ping, 2-ping, 1-hour-head, and the Codex name 30-min-ping. Alias 5-min-ping means auto.
  • Each row has providers: anthropic, openai or any. The proxy does not enforce it. A picker uses it.

What changed

  • config/strategy.go: the table (keys, spends, desc, copied word for word from settings.py), the alias, lookup, and StrategiesJSON.
  • cache.strategy: <name> in proxy.yaml. The proxy fills the cache: keys the file does not set.
  • Override rule: a key present in the file wins, also when its value is zero or false. The proxy checks presence in the YAML, not the value.
  • An unknown name is a config error that lists the known names.
  • context-guru-proxy strategies prints the table as JSON. --json is accepted too.
    • Why: the binary already has subcommands (import-history), and the plugins already run the binary. A new HTTP route needs a running proxy.
  • none sets no keys. The proxy applies no default strategy itself.
  • 30-min-ping (openai) sets only keepalive: true, as the Codex plugin writes today. Its desc is the Codex picker wording.
  • strategies also prints presets: every preset the proxy registers (config.PresetNames()). The proxy has no list of the short picker ladder (off ... ultrahigh), so none is added.
  • A drift test (TestStrategyTableMatchesCodexPlugin) checks the Codex plugin source text: the strategy choices, the config it writes, the picker wording, and that each preset it lists is registered.
  • A drift test (TestStrategyTableMatchesPlugin) reads settings.py with python3 and compares every name, alias, default, spends, desc and key. It stays until the Claude Code plugin reads the proxy.
  • Round 1 fixes: docs/data-dependence.md rows, 30-min-ping in the name lists, null-key note, comment fix.
  • A short section in docs/how-to/cache-keepalive.md.

How it was tested

  • Eval box, -race, go vet, gofmt clean:
    • ./config/... ok (72 s)
    • ./cmd/context-guru-proxy/... ok (37 s)
    • ./proxy/... ok (518 s)
  • Mutations, each made a test fail, then restored:
    • lookup always returns auto: 3 tests fail
    • override ignored: 1 test fails
    • one table value changed: the drift test and the fill test fail
    • drift comparison disabled: the fill test still fails, so the drift test is the only guard for the plugin match when the table and the fill test agree (the drift test fails alone in the third case above)
  • Codex drift test mutations (changed desc, changed keepalive value) both fail the test.
  • No binary in the diff.

Follow-ups

Open questions

  • Should the proxy own the short preset ladder? Today it does not.

Closes #980

🤖 Generated with Claude Code

Add cache.strategy (none, auto, 1-ping, 2-ping, 1-hour-head) with one
table in config/strategy.go. A key set in the file wins over the
strategy. Add `context-guru-proxy strategies` to print the table as
JSON. A drift test pins the table to settings.py.

Closes #980

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Add 30-min-ping (openai), a providers field on each row, and the preset
list in `strategies` output. Add a drift test for the Codex plugin.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 b57d4c9b2fe0 blocking

Verdict: blocking

Findings

  1. docs/data-dependence.md:136 — the PR adds named cache strategies but does not update the data-dependence table
    • What fails: the doc tells a user "Find your preset and your cache strategy below". The cache-strategy table lists only none, 5-min-ping and 1-hour-head. After this PR the proxy accepts 6 names. auto (the plugin default), 1-ping, 2-ping and 30-min-ping have no row. 5-min-ping is now only an alias, and no picker shows it. The ping strategies and 30-min-ping spend the caller's credential and need the stored request bytes, the same class as the 5-min-ping row, so a row is meaningful for each.
    • Proof: git diff 569c609b..HEAD touches 5 files; docs/data-dependence.md is not one of them. The table is at docs/data-dependence.md:138-142. CLAUDE.md, "Metadata first": every PR that adds or changes a feature states its data dependence and updates docs/data-dependence.md.
    • Fix: add rows for auto, 1-ping, 2-ping and 30-min-ping (or one row for the ping family), rename the 5-min-ping row to auto and note the alias, and name a "Decided by" person for each new row. State the feature's data dependence at the top of the PR.

Non-blocking

  • config/strategy_test.go:20 — TestStrategyTableMatchesPlugin fails, not skips, when python3 is missing. So go test ./config/... fails on a machine without python3. The comment says a skip would prove nothing. Fine as a choice; worth a line in CONTRIBUTING.md.
  • cmd/context-guru-proxy/main.go:78 — the comment says "--json is accepted and changes nothing". The branch ignores every argument, not only --json.
  • docs/how-to/cache-keepalive.md:75 and config/config.go:92 — the lists of strategy names omit 30-min-ping, which the table and the strategies command now return.
  • config/strategy.go:164 — a key set to null counts as "set". Example: strategy: 1-ping plus keepalive_max_pings: (no value) skips the fill, and Resolved() then gives K=2, not 1. Arguable; document it or treat null as unset.
  • cmd/context-guru-proxy/main.go:76 — before this PR, context-guru-proxy strategies started the proxy (flag parsing stops at a positional arg). Now it prints the table and exits. Same shape as import-history; name it in the PR per the behavior-change rule.

What I checked

  • The full diff 569c609..HEAD, both commits, and the code around each change (config/config.go, cmd/context-guru-proxy/main.go, docs).
  • Every strategy key exists as a cache: field in CacheConfig, so the KnownFields(true) decode of the filled keys cannot reject a table row.
  • LoadBytes order: the strategy fills run before Cache.validate(), so a filled value is validated. 2-ping sets keepalive_max_pings_1h: 2, under the cap of 3 (internal/modelinfo/cachefrac.go:30). Idle values 240 and 3540 pass the lifetime checks.
  • 1-hour-head sets the deprecated head_ttl_min_tokens: 50000. Resolved() turns that into 200,000 bytes, the same as the default gate, so the row behaves as its desc says.
  • Preset interplay: a preset document cannot declare cache: (the KnownFields guard in applyPreset), so a strategy and a preset cannot fight over the same keys.
  • tenant/configmigrate.go rewrites raw YAML nodes, not the decoded Config, so strategy-filled keys are not frozen into stored tenant configs.
  • I ran the pyDump script from strategy_test.go against context-guru-plugin/scripts/settings.py (python3, read-only). Default, alias and all 5 rows match the Go table in name, order, spends, desc and key values. The Go table adds only 30-min-ping, so TestStrategyTableMatchesPlugin should pass. I did not run the Go test itself.
  • I checked every string TestStrategyTableMatchesCodexPlugin pins in codex-marketplace/plugins/context-guru/scripts/codex_plugin.py and skills/cache-strategy-picker/SKILL.md: all present.
  • Fail-open: config errors refuse to load at startup, the existing strict-loader contract. No request-path change is in this PR.
  • No Go builds or tests were run; live tests are not approved.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 b57d4c9b2fe0 approve

Verdict: approve

Findings

None.

Non-blocking

  • config/config.go:92, config/strategy.go:12, docs/how-to/cache-keepalive.md:75 — all three name lists say the table holds none, auto, 1-ping, 2-ping, 1-hour-head. Commit 2 added 30-min-ping as a sixth row but updated no list. An operator who reads only the doc cannot learn that strategy: 30-min-ping exists. Fix: add the name to the three lists.
  • config/strategy.go:147 (30-min-ping) — the row sets only keepalive: true. On a proxy that also serves Anthropic sessions, that turns the Anthropic keep-alive on too (240 s idle, 2 pings, 20k prefix floor), not just the OpenAI one. Providers: ["openai"] is documented as advisory, and this is the exact file the Codex plugin writes today, so the strategy adds no new behavior. Worth a sentence in the row's Desc.
  • config/strategy.go:117 (1-hour-head) — the row sets the deprecated head_ttl_min_tokens: 50000, not head_ttl_min_bytes: 200000. It resolves to the same 200000-byte gate (CacheConfig.Resolved), so behavior is right. The deprecated key is kept for byte parity with the plugin table, which must run on older proxies. Fine, but the proxy's own table could use the current key.
  • Settings-form interaction (config/form.go) — CacheForm does not model strategy, so the key survives a settings save (unknown keys are preserved), but the save also writes the strategy's current values as explicit keys, because cacheForm renders the strategy-filled config. A later hand-edit of the strategy name then keeps those frozen keys, since an explicit key wins. This follows the documented rule ("a key the file sets itself always wins"), and the plugin manages its strategy files by marker, not through the form. No change asked; noted so the behavior is known.
  • config/strategy_test.go:30 — the drift test hard-fails when python3 is missing (no skip, by stated design). This is an established pattern in this repo (context-guru-plugin/*_test.go, deploy/harbor/*_drift_test.go already exec python3), and CI's ubuntu runners carry it. No change asked.

What I checked

  • Read the full diff (git diff 569c609b..HEAD, both commits) and CLAUDE.md, docs/design.md.
  • applyStrategy logic: early-out on empty name, alias resolution, unknown-name error, the "explicit key wins" rule via a second non-strict unmarshal into map[string]yaml.Node, the marshal/re-decode fill with KnownFields(true). Checked that yaml.v3 leaves untouched struct fields alone on partial decode, that every key in the table exists on CacheConfig, and that all filled values pass CacheConfig.validate (idle 240 < 300, idle 1h 3540 < 3600, pings 1h 2 ≤ cap 3, head gate 50000 within bound).
  • Order of operations in LoadBytes: preset, mode, strategy, validate. Rich presets cannot declare cache: (the KnownFields scratch-struct guard), so preset + strategy cannot fight.
  • Callers of LoadBytes/Load (proxy main, adaptctl, cg-transcript-replay, form, Validate): all get the strategy applied consistently; no path parses cache: outside it.
  • Settings-form round trip (config/form.go): ApplyForm preserves unknown keys, so strategy: survives a save; cacheForm renders resolved values; formbugs_test.go reflects over CacheForm (not CacheConfig), so the new field breaks nothing.
  • Tenant config migration (tenant/configmigrate.go): rewrites only extract_llm/extract_llm_sweep, never cache:.
  • Drift tests: read context-guru-plugin/scripts/settings.py (STRATEGIES, DEFAULT_STRATEGY, STRATEGY_ALIASES) and compared every row, key, value and desc against the Go table — they match, count check py 5 + 1 = go 6 holds, and the positional comparison is valid because the Codex row is last. Verified the ast-based pyDump execs only the three assignments, in file order, so STRATEGIES's reference to DEFAULT_STRATEGY resolves.
  • Codex drift test: verified the pinned strings exist in codex_plugin.py (choices=("none", "30-min-ping"), the 8-space-indented "cache:\n" / " keepalive: true\n" pair) and that the 30-min-ping desc appears in the picker SKILL.md after whitespace normalization.
  • StrategiesJSON: deterministic (sorted maps), SetEscapeHTML(false) keeps >=/<= readable, presets come from PresetNames().
  • The strategies subcommand in cmd/context-guru-proxy/main.go: dispatches before flag parsing, read-only, exit 0/1; mirrors the import-history pattern above it.
  • Behavior-change rule: no strategy key means nothing runs (tested by TestNoStrategyChangesNothing); the feature is opt-in, so no existing config changes behavior.
  • Live tests were not run (not approved); this review is read-only.

Document the strategies in data-dependence.md. Add 30-min-ping to the
name lists. Say in its desc that keepalive: true also turns on the
Anthropic keep-alive. Document null keys. Fix the subcommand comment.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 1 reply. New head df2c4b7c.

Reviewer 1

  1. Blocking: data-dependence rows. Fixed in df2c4b7. docs/data-dependence.md now has auto (alias 5-min-ping), one row for 1-ping, 2-ping and 30-min-ping, and 1-hour-head. A "Decided by" column is added. I used David Amid, docs: document which components depend on stored data, at three storage levels #569, the author of the original rows. The owner must confirm. The PR body now has a Data dependence line.
  2. Name lists. Fixed: config/config.go, config/strategy.go, docs/how-to/cache-keepalive.md name 30-min-ping.
  3. Subcommand comment. Fixed: it says all further arguments are ignored.
  4. Null key. Fixed by documentation, no behavior change: comment in config/strategy.go and a line in the how-to.
  5. Old strategies behavior. Named at the top of the PR body.
  6. python3 hard-fail. Kept. The repo already does this in context-guru-plugin/*_test.go and deploy/harbor/*_drift_test.go. A skip would hide drift.

Reviewer 2

  1. Name lists. Fixed, as above.
  2. 30-min-ping desc. Fixed. The desc starts with the Codex picker wording. It adds: "On a proxy that also serves Anthropic, keepalive: true also turns on the Anthropic keep-alive with the proxy defaults." The Codex drift test now compares the part before the first ". " with SKILL.md, and checks the added sentence is present.
  3. head_ttl_min_tokens in 1-hour-head. Kept. It gives byte parity with the plugin table, and older proxies reject the new key. The result is the same 200000-byte gate.
  4. Settings form freeze. Kept. It follows the documented rule that a key in the file wins.
  5. python3 hard-fail. Kept, as above.

Tests on the box: go vet clean, go test -race ok for ./config/... and ./cmd/context-guru-proxy/....

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 df2c4b7cc5ee approve

Verdict: approve

Findings

None.

Earlier findings

  • Reviewer 1, round 1, finding 1 (data-dependence table): fixed in df2c4b7. docs/data-dependence.md:138-146 now has a row for auto (with the 5-min-ping alias noted), one row for 1-ping / 2-ping / 30-min-ping, and 1-hour-head, plus a "Decided by" column. The PR body states the data dependence at the top, as the rule asks. I checked the attribution: issue #569 is the issue that created that doc, opened by amiddavid, so "David Amid, #569" is accurate.
  • Reviewer 1, round 1, non-blocking: name lists fixed (config.go, strategy.go, how-to); subcommand comment fixed; null-key rule documented in strategy.go and the how-to, with no behavior change, which is what I asked for; the old strategies invocation behavior is named at the top of the PR body; the python3 hard-fail is kept with a reason — I verified the reason: context-guru-plugin has 8+ test files that exec python3, so the pattern is established. Accepted.
  • Reviewer 2, round 1 (approve, 5 non-blocking notes): name lists and the 30-min-ping desc fixed. The head_ttl_min_tokens key is kept for byte parity with the plugin table; I verified in round 1 that it resolves to the same 200,000-byte gate, so the reason stands. The settings-form freeze is kept under the documented "a key in the file wins" rule; reviewer 2 asked for no change. Accepted.

Non-blocking

  • docs/data-dependence.md:143 — the combined row says 1-ping, 2-ping, 30-min-ping "differ only in how many pings and when". 30-min-ping also targets OpenAI and leaves the Anthropic keys at proxy defaults rather than the auto values. The storage-level claim in the row is right, so this is wording only.
  • docs/data-dependence.md:146 — the note under the table cites config/strategy.go. The rows themselves keep their plain-word reasons, so the rule ("the reason in plain words, not a code reference") holds; the citation is a pointer, not the reason.
  • The reply says the "Decided by" owner must confirm before merge. David Amid is the PR author, but the confirmation is the merge gate's to enforce, not this review's.

What I checked

  • Last review: round 1, b57d4c9, 2026-11-09T16:36:37Z.
  • New commits read: 1 — df2c4b7 "fix(config): address round 1 of the strategy review". Full diff read (git diff b57d4c9b..HEAD, 6 files), plus the final state of each changed region.
  • Read in full: 2 reviews, 1 comment, 0 inline comments (the inline list is empty), from the three saved files; also the PR body, to verify the author's two claims about it.
  • New items since my last review: reviewer 2's round-1 review (checked each of its 5 notes myself), the author's round-1 reply (mapped every item to a fix or a reason), commit df2c4b7, and the PR body.
  • The 30-min-ping desc change cannot break TestStrategyTableMatchesPlugin: that test compares only the 5 settings.py rows (indices 0-4), and 30-min-ping is row 6 in the Go table.
  • The updated Codex test splits the desc at the first ". ". I checked the desc: the first ". " falls after "quota", the picker part is the old desc, and the normalized SKILL.md contains it (verified in round 1). strings.Cut needs Go 1.18+; the repo is Go 1.26.
  • The data-dependence table renders as a 5-column table with 5 columns in every row.
  • The null-key and name-list doc changes match the code behavior (applyStrategy checks key presence in the raw document; the fill skips a present key).
  • No Go builds or tests were run; live tests are not approved.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 df2c4b7cc5ee approve

Verdict: approve

Findings

None.

Round-1 findings, re-checked

Mine (all non-blocking in round 1):

  1. Name lists missed 30-min-ping — fixed. config/config.go:92, config/strategy.go:16 and docs/how-to/cache-keepalive.md:77 now name it.
  2. 30-min-ping desc said nothing about the Anthropic keep-alive — fixed. The desc adds the sentence about keepalive: true turning on the Anthropic keep-alive with the proxy defaults. The Codex drift test was updated correctly: it cuts the desc at the first ". " and compares only the picker part with SKILL.md. I verified there is no earlier ". " in the desc, and that the picker part is present in the whitespace-normalized SKILL.md (the text wraps across lines 8-9 there, which is why the test normalizes).
  3. 1-hour-head uses the deprecated head_ttl_min_tokens — author kept it, reason accepted. The reason is right and stronger than stated: the drift test compares the Go row against settings.py key by key, and the plugin's row uses the deprecated key, so the Go table cannot switch to head_ttl_min_bytes without breaking the pin. Behavior is identical (Resolved() maps 50000 tokens to the 200000-byte gate).
  4. Settings-form freeze of strategy values — author kept it, reason accepted. It follows the documented rule that a key in the file wins.
  5. Drift test hard-fails without python3 — author kept it, reason accepted. I verified the precedent myself in round 1 (context-guru-plugin/*_test.go, deploy/harbor/*_drift_test.go).

Reviewer 1's:

  1. Blocking: data-dependence rows missing — fixed. docs/data-dependence.md:137-143 now has none, auto (with the 5-min-ping alias noted), one family row for 1-ping/2-ping/30-min-ping, and 1-hour-head, each with a "Decided by" entry (David Amid, #569, the author of the original rows). The storage claims are accurate: every ping strategy needs the stored request bytes, 1-hour-head keeps nothing. The PR body states the data dependence at the top and says the PR changes none — I read the body and the claim matches the diff (the strategy only fills existing config keys; nothing new is stored).
  2. Name lists — fixed, same as mine.
  3. Subcommand comment — fixed (cmd/context-guru-proxy/main.go:78 now says all further arguments are ignored).
  4. Null key counts as set — fixed by documentation, no behavior change. The RULES comment in config/strategy.go and the how-to line are accurate: a null value decodes to the zero value, the row does not fill it, and Resolved() applies the library default.
  5. Old strategies subcommand behavior named in the PR — verified present at the top of the PR body.
  6. python3 hard-fail — kept, reason accepted (same as my item 5).

Non-blocking

  • docs/data-dependence.md:141 — the family row says 1-ping, 2-ping, 30-min-ping "differ only in how many pings and when". 30-min-ping also differs in the prefix floor: it sets only keepalive: true, so keepalive_min_prefix_tokens stays at the 20000 default, while auto/1-ping/2-ping set 80000. The storage claim of the row is unaffected. Optional: drop "only" or name the floor difference.

What I checked

  • Last review: round 1, b57d4c9, 2026-11-09T16:38:03Z.
  • New commits read: 1 — df2c4b7c fix(config): address round 1 of the strategy review.
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from .review-in-reviews.txt, .review-in-comments.txt, .review-in-inline.txt).
  • New items since my last review, and what I did about each:
    • Reviewer 1's round-1 review (posted 16:36:37Z, before mine; read now in full for the first time). Its blocking finding is the data-dependence table; checked the fix against it, see above. Its non-blocking items overlap mine plus the null-key and subcommand-behavior points; all addressed or kept with a reason I verified.
    • The author's round-1 reply (16:41:42Z). Every claim in it checked against the diff and the PR body: name lists, desc change, data-dependence rows with the Decided by column, null-key documentation, subcommand comment, and the two PR-body statements (behavior-change note, data-dependence line) — all present and accurate.
    • The fix commit df2c4b7c (6 files). Read the full diff and each changed file around the change: docs/data-dependence.md section in place, the updated TestStrategyTableMatchesCodexPlugin (the strings.Cut split point, the SKILL.md normalization, the added-sentence assertion), the RULES comment, the applyStrategy presence comment, and the two name lists.
  • The fix commit adds no code-path change: only comments, doc text, one desc string, and a test adjustment. The Go table still has 6 rows, so the drift-test count check (py 5 + 1 = 6) still holds, and the first 5 rows are untouched, so TestStrategyTableMatchesPlugin is unaffected by the desc change (row 6 is not compared against settings.py).
  • Live tests were not run (not approved); this review is read-only.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

Owner confirmation (David Amid), in the opencode-review session, 2026-11-09:

  1. "Decided by: David Amid, docs: document which components depend on stored data, at three storage levels #569" on every cache-strategy row in docs/data-dependence.md: confirmed.
  2. Behavior change: context-guru-proxy strategies now prints the strategy table and exits. Before, the proxy ignored the extra word and started. Approved.
  3. Release: this PR goes into v0.7.1.

@amiddavid
amiddavid merged commit b49cbeb into main Nov 9, 2026
9 checks passed
amiddavid added a commit to AIMikav/context-guru that referenced this pull request Nov 9, 2026
- Remove the plugin's own copy of the strategy table. Read it with
  "context-guru-proxy strategies" (from rossoctl#987). There is no fallback
  for an older binary: the plugin logs an error that says to update.
- Run the command with a loopback port 0 and a 5 s limit. An older
  proxy treats the word as an argument and starts serving.
- Offer only strategies whose providers match a routed provider.
  The default is the proxy default. An unfit default runs none.
- Write "cache.strategy: <name>" to proxy.yaml. The proxy fills the keys.
- Pin the download to v0.7.1, the first release with "strategies".
- Tests: fake table, provider filter, old-binary error, kill at the limit.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
amiddavid pushed a commit that referenced this pull request Nov 10, 2026
Adds an OpenCode plugin (opencode-plugin/). It installs the proxy,
routes OpenCode's Anthropic and OpenAI providers through it, and adds
status, install, update, uninstall, preset and cache-strategy
commands, with native pickers in the terminal app. It reads the cache
strategies from the proxy (context-guru-proxy strategies, #987), so
it needs proxy v0.7.1 or later. It started as Anamika's work in this
PR; the takeover commits are on top of hers.

Status: experimental. The README lists OpenCode (experimental) and
says why: the plugin is new, and a real OpenCode ran it once.

Behavior change: the plugin always starts the proxy with content
capture off (--dashboard-content=false and DASHBOARD_CONTENT=0), even
when DASHBOARD_CONTENT is set in the environment. It affects OpenCode
plugin users who set DASHBOARD_CONTENT. Before, the proxy followed the
environment. The owner approved this on 2026-11-10.
Data dependence: the plugin keeps only its own metadata (ports, pids,
paths, a hash of the project path). It stores no message text.

Real test: OpenCode 1.19.5 in a throwaway HOME, proxy v0.7.1, the
plain gateway as upstream. A request through the proxy returned 200,
with the real OpenCode session id in the dashboard DB, and
content_capture=false with DASHBOARD_CONTENT=1 set. Preset and
strategy switches, uninstall and fail-open worked. The native pickers
open from the ctrl+p palette ("Context Guru"). /context-guru-preset and
/context-guru-strategy are the chat commands only, so each slash name
shows once (owner decision, option A, 2026-11-10; checked in the real
TUI at 6244d0c).

Owner's yes, 2026-11-10, in the integrator session: reviewer 2's round-4 finding rejected ("no one used opencode before. it is still in development and testing").
DCO: commit d21ea6d (Anamika) has no Signed-off-by; the owner accepted the risk, 2026-11-10, in the integrator session ("483 c").
Reviews: offload round 4 at f2bc703: reviewer 1 (GLM) approve; reviewer 2 (GLM) blocking, rejected by the owner.
Reviews: offload round 5 at 6244d0c (the option A delta only, 1 reviewer at the owner's request): reviewer 1 (GLM) approve, no findings.
Owner's yes, 2026-11-10, in the integrator session, to round 5 with one reviewer: "yes".

Signed-off-by: AIMikav <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5
amiddavid added a commit that referenced this pull request Nov 11, 2026
)

The Codex plugin now reads the cache strategies and presets from the
proxy (context-guru-proxy strategies, #987) and drops its own copy.
The choices none and 30-min-ping, the texts, the default and the
effective proxy config are the same; a Go test compares the whole
config. The config file now says strategy: <name>; old keepalive:
files are still read. The strategies probe runs the binary with a
5-second limit, with DASHBOARD=0, without every DASHBOARD_*,
SESSION_STATE*, CG_RECORD_*, ARCHIVE_*, CONTROL_DB, UPSTREAMS, STORE
and IDLE_EXIT variable, and in a fresh temp dir, so an older binary
that starts serving cannot open the user's databases. Refs #980.

Behavior change: Codex users on a proxy older than v0.7.1 (v0.7.0
included). setup, configure and configure --show now refuse with
"update the proxy to v0.7.1 or later"; before, they worked. There is
no fallback table. /context-guru:update works on an old proxy.
Owner's yes, 2026-11-11, in the integrator session: "u have my yes on both" (the old-proxy error for Claude Code and Codex users, and keeping the old preset behavior).

Data dependence: none.

Reviews: offload rounds 1-2 with 2 GLM reviewers (findings fixed);
rounds 3 and 4 with 1 GLM reviewer, at the owner's request ("this is
correct", 2026-11-11, in the integrator session). Round 4 approves at
e1177f9 with no findings: it checked the probe scrub against
v0.7.0's environment variables and the merge of main.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
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.

Move the cache strategy table into the proxy

1 participant