Skip to content

fix(agent): honor prompt_caching.cache_ttl=off on MoA and fallback stub paths - #76622

Merged
kshitijk4poor merged 5 commits into
NousResearch:mainfrom
kshitijk4poor:salvage/76113-cache-ttl-off-stubs
Aug 2, 2026
Merged

fix(agent): honor prompt_caching.cache_ttl=off on MoA and fallback stub paths#76622
kshitijk4poor merged 5 commits into
NousResearch:mainfrom
kshitijk4poor:salvage/76113-cache-ttl-off-stubs

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Summary

prompt_caching.cache_ttl: off now applies globally: MoA advisor/aggregator decoration and auxiliary fallback replans previously resolved cache policy against a blank stub without _cache_disabled, so they kept injecting cache_control markers after the operator disabled caching (#76085, contract from #33555).

Salvage of #76113 by @686f6c61 — all four commits cherry-picked with authorship preserved (includes the Co-authored-by: @JoaoMarcos44 trailer from the #76121 consolidation). One follow-up commit on top applies review findings.

Changes

  • (contributor commits, verbatim) blank_cache_policy_stub() single sanctioned stub factory carrying _cache_disabled; config-detection helper; tri-state threading through MoA advisor fan-out, one-shot synthesis, and the prepared aggregator; 12 regression tests.
  • (follow-up) cache_ttl_means_disabled() shared predicate — agent_init and the stub-path helper now use one disable-synonym source so the two detection sites cannot drift; consistent not-None injection guard in aggregate_moa_context; replaced a vacuous test assertion with the intended input-non-mutation check; predicate-parity regression test.

Validation

Check Result
New + adjacent suites (cache/MoA/auxiliary/init) 286 passed, 3 skipped
Enabled-path parity probe vs main (real imports, 4 scenarios) byte-identical (md5 match)
Disabled path markers stripped on all stub paths
Mutation check (defeat stub flag) 8 tests fail → restore → green
_cache_disabled leak into call_llm wire kwargs none (all 3 call sites splat originals)
ruff clean

Fixes #76085.
Based on #76113 by @686f6c61 (with @JoaoMarcos44 credited via trailer). Requires #76618 (attribution mapping) to merge first.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/config Config system, migrations, profiles P0 Critical — data loss, security, crash loop sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) labels Aug 2, 2026
686f6c61 and others added 5 commits August 2, 2026 11:31
Blank SimpleNamespace stubs used by MoA decoration and
plan_cache_sections_for_destination never set _cache_disabled, so
anthropic_prompt_cache_policy re-injected cache_control markers after
operators turned caching off. Stamp the disable onto those stubs from
an explicit flag or the live config, and pass the agent flag from the
MoA aggregator path.

Fixes NousResearch#76085
Avoid F401 from ruff/pyflakes on the NousResearch#76085 regression file.
Prepared-aggregator facades built via __new__ lack _agent. Accessing
self._agent raised inside the planner try and bool-coercion of a missing
snapshot forced False, suppressing config fallback for cache_ttl=off.
Pass a tri-state value and add a no-agent/config-off regression.
Absorb the useful deltas from the parallel NousResearch#76121 approach: a single
blank_cache_policy_stub factory so _cache_disabled cannot be left off
hand-rolled SimpleNamespaces, and pin the live agent disable onto MoA
advisor fan-out and one-shot aggregate_moa_context decoration so those
paths track conversation state rather than a fresh config re-read.

Keeps the earlier tri-state prepared-aggregator no-agent fix. Adds
factory and synthesis/advisor regressions.

Coordinates with NousResearch#76121 / NousResearch#76085.

Co-authored-by: JoaoMarcos44 <87440198+JoaoMarcos44@users.noreply.github.com>
…d stub paths

Follow-ups from review of NousResearch#76113:
- Extract cache_ttl_means_disabled() as the single disable-synonym
  predicate; agent_init and prompt_caching_disabled_from_config both use
  it so the two detection sites can no longer drift (drift would recreate
  the NousResearch#76085 bug class).
- Mirror _run_reference's not-None injection guard in
  aggregate_moa_context (stamping None was a harmless no-op copy).
- Replace a vacuous trailing test assertion with the intended
  input-non-mutation check; drop a stray blank line.
- Add a predicate-parity regression test (unknown TTL values keep
  caching enabled, matching historical agent_init semantics).
@kshitijk4poor
kshitijk4poor force-pushed the salvage/76113-cache-ttl-off-stubs branch from 7d2b1fe to ff6e4b5 Compare August 2, 2026 06:01
@kshitijk4poor
kshitijk4poor enabled auto-merge (rebase) August 2, 2026 06:01
@kshitijk4poor
kshitijk4poor merged commit 88a629b into NousResearch:main Aug 2, 2026
37 of 38 checks passed
@kshitijk4poor
kshitijk4poor deleted the salvage/76113-cache-ttl-off-stubs branch August 5, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P0 Critical — data loss, security, crash loop sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prompt_caching.cache_ttl disable is bypassed on stub-resolved cache-plan paths (MoA aggregator/advisors, auxiliary fallbacks)

3 participants