fix(openai-compat): retain complete calls - #1
Open
calclavia wants to merge 11 commits into
Open
Conversation
…Effect-TS#8162) Co-authored-by: Giulio Canti <giulio.canti@gmail.com>
arjunkmrm
force-pushed
the
clavia/ai-providers
branch
from
September 14, 2026 05:46
60c67e9 to
57c6005
Compare
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.
OpenAI-compatible streams can finish with
lengthafter 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
lengthterminal and usage stay intact for the caller's truncation policy. Normaltool_callsparsing 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:
@tardie/ai-openai-compat@4.0.0-rc.113-clavia.1reproduces the missing call with LegalEnv's zero-network script; the generated patched package passes it in a clean external Bun installation.pnpm lint-fixandpnpm --filter @tardie/ai-openai-compat buildpass.pnpm checkreports the existing unrelated unusedmetadatabinding atpackages/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.