Repository navigation
Fix handoff usage and schema setting changes in tool loops - #395
Merged
Merged
Conversation
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.
This PR fixes two problems in the provider tool loops on dynamic profile sessions. When a streaming response handed off from an HTTP model to a local structured model, the handoff rebuilt the prepaid snapshot with the earlier usage added and without its prepaid token, so the session counted the local requests twice. The rebuilt snapshot now keeps the token and carries the handed-off usage separately, and the session counts only the part of that usage that it hasn't counted yet.
When a tool callback changed a profile's schema prompt setting and kept the model, the next request in that response still used the old setting, because each provider computed the schema text once before its request loop. All five providers now compute the schema text after each context resolution, through one shared helper. Ordinary sessions keep the setting from the call site.