fix: expose unavailable provider budget diagnostics safely - #59
Merged
Merged
Conversation
Emit orchestrator:provider_budget with result="unavailable" whenever an invoked request-budget path yields no usable native count, so a session that silently fell back to estimate-based compaction is visible. Why: a live run produced zero orchestrator:provider_budget events while check_request_budget and count_measured_request returned None silently. Scope: diagnostic only. The initial compatibility fallback, the post-concrete fail-closed error, malformed-decision rejection, return types, policy target, compaction stages, retries and the success event schema are unchanged. A provider that never advertised request_budget keeps its historical silent path. Emits are best-effort and never swallow cancellation. Verified: source-only lane -- AST parse, compileall, git diff --check. Test suites not executed here; the manager runs them in the DTU. Breaking changes: none. Generated with Amplifier Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Generated with Amplifier Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
orchestrator:provider_budgetunavailable outcomes when an invoked provider-budget path cannot produce a usable native count.Why
A missing native count should be observable without fabricating numeric measurements or changing compaction policy.
Compatibility
orchestrator:provider_budgetcan now emitresult: "unavailable". These payloads omit fields such asestimated_input_tokens,input_limit_tokens, andcontext_token_budget; consumers must branch onresultand treat those numeric fields as optional.Known diagnostic-label nuance: an
allow_unprovenrecovery probe after a server-overflow path can be reported asinitial_fallbackwithattempt > 0. This is diagnostic labeling only; policy and recovery behavior are unchanged.No dependency changes or breaking changes are intended beyond the additive diagnostic outcome above.
Validation
pytest -q -p no:cacheprovider -m 'not live' tests, in an isolated environment with Python 3.12.3 and Core 1.6.1.Joint live validation with Gemini #50 and the existing Context implementation preserved native measured-compaction behavior in both streaming modes: 879,659 native input tokens reduced to 443,422, below the effective 499,600 target. The next ordinary request remained at 443,643 native tokens (nonstreaming) and 443,642 (streaming).
The SDK prompt counts matched three of four comparisons exactly. Nonstreaming next-request SDK usage was 443,945, a 302-token (0.0681%) difference within the predeclared 1% tolerance. The final run's 10 count requests and four generations all returned HTTP 200, with no unavailable/estimate fallback. Normalized payload parity, required instructions, final five tool pairs and durable removal of the oldest full tool body were verified.
Live scope was the Gemini Developer API,
gemini-3.8-flash, SDK 2.23.0, synthetic history and declared tools with modeNONE; it does not establish endurance or live post-compaction tool-execution coverage. Earlier harness failures are separate from this final successful run.Independent read-only review found no ship blockers. The initial commits' unexecuted-test notes describe creation time; the final candidate was subsequently validated as above.