Uh oh!
There was an error while loading. Please reload this page.
fix: tolerate raw tool-call entries in precontext (#1) - #7
Merged
Conversation
`to_interfaze` re-validated the completion through a strict `Precontext`
(name required), but the server appends raw model tool-calls
`{toolCallId, toolName, input}` to `precontext` on any tool / run_code turn
— no `name`/`result` — so `create()` raised `ValidationError` on those turns.
Make `Precontext` lenient (optional `name`, `extra="allow"`), mirroring
openai-python's "validate loosely, preserve everything": re-validation now
never raises, well-formed entries stay typed, and raw tool-call entries are
preserved as extras. Typed `choices`/`message` are unaffected.
Adds a mixed-precontext fixture + regression test.
Fixes#1
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 17, 2026
Abhinavexist added a commit
that referenced
this pull request
Jul 21, 2026
…est-id, escape hatches - #1 .stream() now yields OpenAI ChatCompletionStreamEvents (content.delta/done, tool-call events) via ChatCompletionStreamState; <think>/<precontext> stripped from content events; text_deltas() for plain tokens; create(stream=True) unchanged. - #2 streamed usage + system_fingerprint captured on get_final_completion(). - #3 _request_id carried onto the returned completion. - #6 parse()/with_raw_response/with_streaming_response exposed on the wrapper (no more AttributeError; parse delegates to the OpenAI client, model default + guard). Rebased onto main (post #7–#11).
This was referenced Jul 21, 2026
Merged
Abhinavexist added a commit
that referenced
this pull request
Jul 22, 2026
…est-id, escape hatches - #1 .stream() now yields OpenAI ChatCompletionStreamEvents (content.delta/done, tool-call events) via ChatCompletionStreamState; <think>/<precontext> stripped from content events; text_deltas() for plain tokens; create(stream=True) unchanged. - #2 streamed usage + system_fingerprint captured on get_final_completion(). - #3 _request_id carried onto the returned completion. - #6 parse()/with_raw_response/with_streaming_response exposed on the wrapper (no more AttributeError; parse delegates to the OpenAI client, model default + guard). Rebased onto main (post #7–#11).
Abhinavexist added a commit
that referenced
this pull request
Jul 22, 2026
…est-id, escape hatches (#20) - #1 .stream() now yields OpenAI ChatCompletionStreamEvents (content.delta/done, tool-call events) via ChatCompletionStreamState; <think>/<precontext> stripped from content events; text_deltas() for plain tokens; create(stream=True) unchanged. - #2 streamed usage + system_fingerprint captured on get_final_completion(). - #3 _request_id carried onto the returned completion. - #6 parse()/with_raw_response/with_streaming_response exposed on the wrapper (no more AttributeError; parse delegates to the OpenAI client, model default + guard). Rebased onto main (post #7–#11).
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 freeto 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.
Issue: #1
Fix. Make
Precontextlenient (name: Optional[str] = None,model_config = ConfigDict(extra="allow")), mirroring openai-python's type strongly, validate loosely, preserve everything:p.name/p.result);p.model_extra["toolName"], etc.);choices/messageare unaffected (keptmodel_validate, not a lossymodel_construct).Tests. Added a mixed-
precontextfixture (MIXED_PRECONTEXT: one{name,result}+ one raw{toolCallId,toolName,input}) and a regression testtest_precontext_tolerates_raw_toolcall_entries. The reporter's exact repro now returns without error.ruff/mypy --strict/pytest(25) all green.