Skip to content

fix(openai-compat): retain complete calls - #1

Open
calclavia wants to merge 11 commits into
clavia/ai-providersfrom
fix/compat-length-tools
Open

fix(openai-compat): retain complete calls#1
calclavia wants to merge 11 commits into
clavia/ai-providersfrom
fix/compat-length-tools

Conversation

@calclavia

@calclavia calclavia commented Sep 12, 2026

Copy link
Copy Markdown

OpenAI-compatible streams can finish with length after delivering a complete tool call. The adapter currently drops every buffered call for that terminal reason, so LegalEnv receives different calls from identical complete arguments depending only on the finish reason.

Parse buffered arguments through the existing secure parser before deciding whether a call is complete. Complete calls retain their identity and parameters; empty, partial, and unsafe buffers remain parameter deltas. The length terminal and usage stay intact for the caller's truncation policy. Normal tool_calls parsing failures retain their existing error behavior.

Core user need: benchmarks must retain complete tool calls on truncated responses; this refactors stream finalization and introduces no execution or retry policy.

Validation:

  • Published @tardie/ai-openai-compat@4.0.0-rc.113-clavia.1 reproduces the missing call with LegalEnv's zero-network script; the generated patched package passes it in a clean external Bun installation.
  • All 252 provider tests pass, including the 37 OpenAI-compatible model tests and shared cross-provider contracts for complete and partial arguments, empty buffers, unsafe JSON, trailing partial JSON, interleaved calls, finish/usage retention, and unchanged malformed normal completion behavior.
  • pnpm lint-fix and pnpm --filter @tardie/ai-openai-compat build pass.
  • Repository-wide pnpm check reports the existing unrelated unused metadata binding at packages/effect/typetest/Schedule.tst.ts:80. It reports no error in the changed source or tests.

Targets clavia/ai-providers, the repository's default branch and source of the published package. The changeset requests a patch release. No live provider request was made.

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.

3 participants