Skip to content

fix(context): context veto outranks classifier retry; exhausted preflight not retryable - #217

Merged
RecursiveIntell merged 11 commits into
mainfrom
fix/context-compaction-port-20261027
Nov 11, 2026
Merged

RecursiveIntell merged 11 commits into
mainfrom
fix/context-compaction-port-20261027

Conversation

@RecursiveIntell

Copy link
Copy Markdown
Owner

Ported from the local context-compaction worktree (4 commits, Oct 26, authored by Josh Stevenson, authorship preserved via cherry-pick).

  • lineage veto and exhausted preflight are not retryable
  • context veto outranks classifier retry on API-like exceptions
  • non-API exhausted-preflight text is non-retryable too
  • test: exercise the preflight estimate-drift telemetry line (167-line test)

Verified NOT on main before porting (main's agent/error_surface.py has zero veto handling; test files absent).

the desktop surfaced retryable=true for turns whose compaction was
vetoed by lineage_integrity_mismatch while unchanged retries
deterministically re-vetoed (5x in 5 minutes, 2026-10-26); recovery is
a context-recovery action, not a resend.

- build_error_surface_from_result: lineage_integrity_veto maps to
  runtime/lineage_integrity_mismatch, retryable=false
- build_error_surface_from_exception: CONTEXT_PREFLIGHT_EXHAUSTED and
  raised lineage vetoes map non-retryable; unrelated gateway exceptions
  keep the legacy retryable verdict (control test)
- RED/GREEN: tests/agent/test_context_veto_error_surface.py
…ptions

Verifier F1 (2026-10-26, VERDICT: FAIL on 1c05eeb5b7): in
build_error_surface_from_exception's API-like branch,
surface['retryable'] = bool(classified.retryable) overwrote the veto's
retryable=False, so a lineage_integrity_mismatch (or
CONTEXT_PREFLIGHT_EXHAUSTED) carried by an exception with status
404/408/413/429/500/502/503/504 still surfaced retryable=true — the
exact resend-loop symptom the commit was meant to remove.

- the deterministic context verdict is computed before classification
  and, when present, overrides the classifier's retry guess on the
  API-like path (context_veto=true marker)
- ordinary API errors keep the classifier verdict (control test)
- RED (on 1c05eeb5b7): test_f1_api_like_veto_stays_non_retryable;
  plus preflight-exhausted variant and no-veto control
Verifier run-2 medium finding: a NON-API exception carrying the
Hermes-owned CONTEXT_PREFLIGHT_EXHAUSTED sentinel (re-raised as a plain
RuntimeError by a transport wrapper) still surfaced
gateway/retryable=True — same deterministic-resend symptom the F1 fix
removed from the API-like path. The message is a Hermes-owned sentinel,
not provider text, so the exception type does not change the verdict.

- the non-API branch now maps the sentinel to
  runtime/context_preflight_exhausted, retryable=False (before the
  generic gateway fallback)
- two tests: plain-RuntimeError sentinel and plain-RuntimeError lineage
  text; 9/9 in the veto suite, 50 error-surface/failover tests green
Verifier run-1 'not checked' item: the drift INFO line added in
8ef3f74722 had no test. Drives the real build_turn_context branch with
the measured incident shape (estimate 1,086,932 vs real provider prompt
898,481, +21.0%): the line is logged with both numbers; below the 15%
threshold and without a real reading, no line. Harness mirrors
tests/agent/test_api_content_sidecar.py.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T19:52:37.802461Z 914811c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 914811c175

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

૮ >ﻌ< ა ci review

ran on ad5060f — Merge branch 'main' into fix/context-compaction-port-2026102

⚠️ Warnings

OSV vulnerability scan · View job

290 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 17m17s vs 18m13s (-5.1%). 12 job(s) slower, 13 faster,

  • Python tests / e2e: -84.0s
  • Python tests / Run tests slice 1/12: +84.0s
  • Python tests / Run tests slice 9/12: -59.0s
  • Python tests / Run tests slice 11/12: +55.0s
  • Context continuity qualification / Native external owner paired source: +53.0s

The acceptance test (test_preflight_drift_telemetry.py) expected a 'Preflight
estimate drift' INFO line that the ported commits never implemented. When the
rough estimate exceeds the last real provider prompt by >=15%, one bounded line
names rough, real, and the +X.X% gap.
@RecursiveIntell

Copy link
Copy Markdown
Owner Author

Fixed in c9e970c: the drift telemetry implementation (agent/turn_context.py) now logs the 'Preflight estimate drift' line at >=15% gap — the acceptance test's missing counterpart is implemented. Verified the exact log format matches the test's assertions.

RecursiveIntell and others added 6 commits October 28, 2026 12:07
…mpt trackers

The preflight drift line assumed last_real_prompt_tokens is numeric.
MagicMock compressors in tests auto-create the attribute (so the getattr
default never applies), and any non-int tracker value exploded on the
'>' comparison (TypeError at agent/turn_context.py:1003). Gate the
telemetry on isinstance(int) so mock and non-numeric trackers skip the
line. Restores the two CI-failing suites (compression budget rearm,
api content sidecar preflight compaction).
@RecursiveIntell
RecursiveIntell merged commit 0daee73 into main Nov 11, 2026
51 checks passed
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