fix: fit measured requests and finalize failed goals - #61
Merged
Merged
Conversation
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
This companion change builds on the optional
fit_outputnegotiation added by the Context dependency (Context PR #44). It deep-clones the assembled request, preserves tools, options, retention, overlays, and tool choice, and tries a bounded output-cap ladder: at most six additional counts, with a 1,000-token floor. Severe sub-10k warnings are included before each candidate count. The accepted, newly counted request object is dispatched unchanged.Goal-turn failures across initial, continuation, and escalation paths now clear the active goal, flush a deferred errored completion exactly once, emit terminal progress, avoid evaluator/judge/summary helpers, and re-raise the original turn error. Cooperative fitting cancellation follows the normal cancellation lifecycle; actual task cancellation still propagates.
Why
Some provider budgets fit when reducing the output reserve increases the provider-reported input allowance. This gives the loop a bounded, lossless negotiation path and ensures failed goal turns do not leave stale active state or pending error completion.
Verification
Fixture-only test correction
The existing hard-fit fixture changes from 40k to 70k supplementary Han characters to restore its intended over-budget precondition after the documented model input-ceiling correction. Assertions are unchanged, and the authentic baseline production passes the corrected fixture.
Non-goals and limits
No Core API, provider/default-meter change, byte-fallback deletion, retention weakening, automatic model change, or required-input protection relaxation is included. Output fitting cannot resolve an independent input ceiling or genuinely oversized required input, and adds at most six extra counts per fit.
The Context dependency is merged in microsoft/amplifier-module-context-simple#44.