Skip to content

fix: capture safe token-count unavailable diagnostics - #144

Merged
Brian Krabach (bkrabach) merged 4 commits into
mainfrom
fix/count-unavailable-diagnostics
Nov 15, 2026
Merged

Brian Krabach (bkrabach) merged 4 commits into
mainfrom
fix/count-unavailable-diagnostics

Conversation

@bkrabach

@bkrabach Brian Krabach (bkrabach) commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

request_budget() returns None on count failures, but safe warnings can be absent from captured sessions. The original Fable count-failure cause remains unknown. This PR adds diagnostics only; it does not claim original-chat recovery.

Change

  • Emit best-effort provider:token_count_unavailable through existing coordinator hooks; mount now contributes its name to observability.events under provider-anthropic, so discovery-based observers subscribe.
  • Allowlist provider, model, count source, category, exception class, SDK HTTP status/request ID. No prompts, bodies, headers, credentials, private configuration, or exception text.
  • Reuse the existing suppression set with (resolved model, category, exception class, HTTP status). Changed safe failures remain visible. A new request ID never bypasses suppression or grows the set.
  • Preserve unavailable None, cancellation, API-call count, deadlines, retry and fit semantics. SDK timeout is classified as timeout. Ordinary diagnostic failures cannot change None.

Tests and capture boundary

The existing offline suite covers real-SDK MockTransport HTTP429/400, timeout, malformed and valid counts; JSON/privacy, no extra requests, missing/failing observer, deadline and cancellation tests.

Review repair adds:

  1. Real Core provider mount, named contribution collection, Core-plus-contributed subscriber discovery, and JSON file capture through the real Core hook registry. Checks timestamp enrichment, synthetic session ID, strict safe payload, unchanged None, and no extra SDK calls.
  2. Same-category HTTP400 then500 are retained, repeated500 with a new request ID is suppressed, and changed exception class is retained.

Boundary: the Core subscriber is not the actual Context Intelligence LoggingHandler. Canonical CI discovery/subscription/writer source was inspected at bf7cfbc82bdfd356e86f7a849622772537956b17. Actual CI-hook capture remains an explicit paired isolated qualification gate handed to parent/worker87, with local-only destinations and synthetic session identity. No dependency was added solely to simulate that gate.

Exact-head validation

Current head e10499b8c9a15d21aa0904b7d0567318e5bc0048: all six ordinary CI jobs passed on Linux/macOS/Windows, Python3.11/3.12: 2659 passed, 1 deselected, 48 warnings per job.
https://github.com/microsoft/amplifier-module-provider-anthropic/actions/runs/43661350635

Host AST-only parsing and diff checks passed; working tree clean. No host pytest/install, DTU, live provider call, production capture or original-session/config access. The existing separately authorized live-vision test remains deselected/UNMET.

Earlier repair head 0c6c8c7 failed only its new strict Core-envelope assertion because Core adds a timestamp; event delivery and JSON write succeeded. Final test accounts for that field explicitly. Prior c23cff5 green did not prove observer discovery.

Scope and remaining gates

Based on main 3204656f784af914de2c3d7d6f7175ad904a00db. Only provider diagnostics/mount registration, request-budget tests and existing README changed. No model/media, context or streaming-loop files. PR133/142 edit this module elsewhere; contextPR38/streamingPR74 retain their owners.

Keep draft: parent Astra/Fable exact-head source closure and actual CI observer capture in coordinated combined isolated qualification are required before merge/adoption. No merge, adoption, serving changes or release is included.

@bkrabach

Copy link
Copy Markdown
Collaborator Author

Exact-head offline validation completed for c23cff54981cdfa82162f4071ec415a48d7a5a8c: https://github.com/microsoft/amplifier-module-provider-anthropic/actions/runs/43659967064

All six jobs passed (Linux/macOS/Windows, Python 3.11/3.12), each with 2657 passed, 1 deselected, 48 warnings. The deselected case is the existing separately authorized live-vision gate, which remains UNMET. Final transport cases explicitly use claude-fable-5-2 and only MockTransport, not a vendor endpoint. Host AST parsing and diff checks also passed; working tree is clean.

No DTU, live provider request, dependency adoption, merge, release, or original-chat continuation was performed. The historical count-failure cause and original-chat recovery remain unproven. Draft stays open for parent-owned Astra/Fable exact-head review and coordinated combined isolated qualification.

@bkrabach
Brian Krabach (bkrabach) marked this pull request as ready for review November 15, 2026 04:16
@bkrabach
Brian Krabach (bkrabach) merged commit 6ea9d0c into main Nov 15, 2026
7 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.

2 participants