Skip to content

fix(loop): finalize bounded native tool turns safely - #50

Merged
Brian Krabach (bkrabach) merged 1 commit into
mainfrom
fix/native-safe-budget-finalization
Sep 8, 2026
Merged

Brian Krabach (bkrabach) merged 1 commit into
mainfrom
fix/native-safe-budget-finalization

Conversation

@bkrabach

Copy link
Copy Markdown
Collaborator

What changed

Completes the loop-streaming downstream needed by the merged provider boundary fixes:

The loop now distinguishes a natural completion at the iteration boundary from a forced finalization. Natural completion does not make a duplicate provider call. Forced finalization preserves the ordinary generic/native tool declarations while sending portable tool_choice="none"; unexpected tool calls are not dispatched or structurally persisted. Cancellation and provider errors close an interrupted tool turn safely, while reasoning blocks, provider metadata, and llm_calls remain accurate.

No provider model names are hardcoded here; provider dialect behavior remains at the provider boundary.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / internal change (no behavior change)
  • Other:

Testing

  • Full local suite: 266 passed.
  • Boundary coverage includes natural completion versus forced finalization, the final request's tool_choice="none", non-dispatch of an unexpected response tool call, cancellation/error closure, native tool-spec retention, reasoning metadata, and accurate provider-call accounting.
  • Provider prerequisites were independently merged with green CI: OpenAI PR #89 (py3.11, py3.12, CLA) and Anthropic PR #116 (Ubuntu/macOS/Windows on py3.11 and py3.12, CLA).

Review focus

  • The normal-completion/forced-finalization boundary must not regress into an extra call for a complete response.
  • The finalization request must retain native declarations for transcript validity while preventing another tool dispatch.
  • The provider merge links above are dependencies/evidence only; this PR does not request or perform an admin merge.

Count actual provider calls, avoid duplicate natural completions, and close
interrupted finalization turns with safe assistant state.

Generated with Amplifier

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
@bkrabach
Brian Krabach (bkrabach) merged commit 2feefe4 into main Sep 8, 2026
5 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