Turn the `reasoning` field of `HuggingFaceModel` responses into `ThinkingPart`s
Closes #10899
Why we make these changes
huggingface_hub declares a reasoning field on chat completion messages and stream deltas, added for gpt-oss in huggingface/huggingface_hub#3338. HuggingFaceModel read only content, so reasoning a provider sent in that field was dropped. reasoning_content stays unmapped on purpose: it is not a huggingface_hub field, and the only recorded value is null. Thanks to @pcbeingused333 for the report and the repro in #10899.
New public surface
None.
User-visible behavior
# message.content='42', message.reasoning='I computed it'
# before: [TextPart(content='42')]
# after: [ThinkingPart(content='I computed it'), TextPart(content='42')]
Streamed delta.reasoning builds the same ThinkingPart through ThinkingPartDelta events. The field's ThinkingPart comes before any <think>-tagged content, and both are kept, as in OpenAIChatModel and GroqModel. Later requests still send every ThinkingPart back as <think> text: Hugging Face's input message has no reasoning field.
Verification
- The non-streamed and streamed tests replay live
openai/gpt-oss-120brecordings through the Hugging Face router's Groq route. Groq sends the reasoning inmessage.reasoninganddelta.reasoning, and the snapshots pin it as aThinkingPartbefore the text. - The field plus
<think>tags and round trip tests mock the client: no recorded response carries both, and no live round trip is recorded. tests/conftest.pyadds the Groqopenai/gpt-oss-120bmapping to_patch_hf_provider_mappings. Without it,huggingface_hubresolves the provider with a synchronousHfApi().model_infocall inside the async request, which the suite's blocking-call detector rejects when recording.- Every existing Hugging Face cassette, streamed and non-streamed, gives the same parts with and without the change.
What changes for existing users
Reasoning a provider sends in the reasoning field now appears as ThinkingParts; responses without it are unchanged.
PR decisions
2026-11-15 · readiness: bug valid, design aligned · iter -
- Decision: Manager blind design review: VALID, ALIGNED; bug reproduces on main 343a77398; every existing HF cassette byte-identical under the fix
- Why: Independent probes in manager/local-notes/readiness/10910/probes
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · ThinkingPart has no id or provider_name · iter -
- Decision: ThinkingPart from reasoning carries only content; vendor part id is constant 'reasoning'
- Why: Groq, Mistral, Cohere precedent; agent_docs/provider-adapters.md sentinel ids
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · field ThinkingPart before tag-split content, both kept · iter -
- Decision: reasoning-field ThinkingPart precedes split_content_into_text_and_thinking output; neither dropped
- Why: Matches OpenAI Chat and Groq ordering
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · round trip unchanged · iter -
- Decision: Keep re-rendering every ThinkingPart as think-tag text on input
- Why: HF ChatCompletionInputMessage has no reasoning field (fields: role, content, name, tool_calls)
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · reasoning_content unmapped (deliberate scope) · iter -
- Decision: Do not map reasoning_content
- Why: Not an SDK field; only wire value seen is Nebius reasoning_content null
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · mock tests, recording parked · iter -
- Decision: Tests stay mocks with a one-line non-VCR reason; live gpt-oss-120b recording parked pending HF_TOKEN; body says wire verified only via SDK field
- Why: No recorded HF response carries reasoning; HF_TOKEN absent on this box
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · docs: no effort-table row, no models/huggingface Thinking section · iter -
- Decision: Drop the effort-table row and the unsourced Thinking section; add one sentence to thinking.md section Hugging Face
- Why: Effort table covers effort translation; DeepSeek-R1 cassette returns think tags inside content, contradicting the native-field claim
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · adopted PR #10910 at 2026-11-15 · iter -
- Decision: Branch-context bootstrapped from existing PR + issue(s). Decisions prior to this entry are backfilled from resolved threads.
- Why: PR predates the branch-context setup
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · pre-push review 1 of 3 at 9e85856c853300e00393c9042680b3bfc9f1b9a5 · iter -
- Decision: reserved: dispatched, outcome pending
- Why: tree ca57a21039a034dab797145a735a346927311470; scope ccef7c9d2..9e85856c8 (full branch); light tier (Haiku) via claude -p from a detached policy-base checkout at ccef7c9d2
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · pre-push review 1 of 3 at 9e85856c853300e00393c9042680b3bfc9f1b9a5 · iter -
- Decision: remediated: streamed test now splits reasoning across two chunks and asserts the ThinkingPartDelta continuation
- Why: tree ca57a21039a034dab797145a735a346927311470; scope ccef7c9d2..9e85856c8 (full branch); one finding (iter test emitted no PartDeltaEvent); candidate worktree unchanged during review
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · no pre-push review at 623870bc0be766c817cd684a00a5da8b709aca3a · iter -
- Decision: Exempt delta: test-only coverage fix since reviewed 9e85856c8
- Why: Exempt-delta row 1: tests/models/test_huggingface.py only; established expectation is issue 10899's thinking deltas when streaming; affected tests pass; chains from reviewed 9e85856c8 (review 1 of 3)
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · no pre-push review at bf88a491be172584a8b47ef3d27f67b492692e2f · iter -
- Decision: Exempt delta: douwebot Optional test tidy (helper moved beside text_chunk, unused finish_reason dropped, comprehension variable renamed)
- Why: Exempt-delta row 1: tests/models/test_huggingface.py only, same inputs and expectations; HF tests pass; chains from reviewed 9e85856c8 (review 1 of 3) via exempt 623870bc0
- Source: https://github.com/pydantic/pydantic-ai/pull/10910#discussion_r4576590609
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · step 7 second opinion queued for David · iter -
- Decision: Manager queued the step-7 second-opinion pick for David; finish PR Review Checks and the final metadata check, then hold in monitor mode until the pick is relayed
- Why: The PR changes what goes back to the provider on the next turn: a reasoning-field ThinkingPart is re-sent as think-tag text
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · step 7 second opinion: none · iter -
- Decision: David picked none on 2026-11-15; enqueue only once the HF recording lands (David holds the token)
- Why: Manager relayed David's pick
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · credit pcbeingused333 everywhere · iter -
- Decision: Keep a thanks line in the PR body, and add 'Co-authored-by: pcbeingused333 82875882+pcbeingused333@users.noreply.github.com' as a trailer on the next pushed commit, in a new commit, never by amending
- Why: David, 2026-11-15: the repo squashes with a blank message, so GitHub builds squash trailers from the PR's commits; a trailer in the body alone will not land
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-15 · credit pcbeingused333: thanks line only · iter -
- Decision: No Co-authored-by trailer for pcbeingused333; the thanks line in the PR body is the credit. 'The trailer is only for authors whose code or fix we used.'
- Why: David, 2026-11-15: pcbeingused333 reported the issue and offered to implement it but contributed no fix code
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
- Supersedes: credit pcbeingused333 everywhere
2026-11-17 · HF_TOKEN provided; recording unparked · iter -
- Decision: David provided HF_TOKEN on 2026-11-17
- Why: Manager relayed: unparked, in-flight; record live openai/gpt-oss-120b cassette, push, re-pass gates; step 7 stays none; manager enqueues
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · live recording denied; held for David · iter -
- Decision: Recording command denied by the auto-mode classifier (Undermining Oversight); not changed, not retried, no cassette written; local commits 57dec5c5a (merge) and the test switch are unpushed
- Why: Dispatch 20261117T043644Z: one try; on a classifier denial report under DAVID with the command unchanged
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · hold recording until allow rule live · iter -
- Decision: David approved a global Bash allow rule for the env-run --mask pytest recording shape; hold the recording until the manager relays 'allow rule live', then run the same exact command once more (2026-11-17)
- Why: Manager relay of David's answer on the classifier denial (local-notes/dispatch-20261117T143137Z.md); rule is in CE review
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · allow rule live; one re-run · iter -
- Decision: Allow rule live (2026-11-17); one re-run of the unchanged recording command
- Why: Manager relayed: allow rule verified in global settings; run through the test-runner as before
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · re-run failed: missing HF provider mapping · iter -
- Decision: One re-run used: blockbuster blocked HfApi().model_info socket.connect, no request sent, no cassette; added ('groq', 'openai/gpt-oss-120b') to tests/conftest.py _patch_hf_provider_mappings locally; next run needs manager approval
- Why: huggingface_hub resolves provider mappings with a sync HfApi call unless HARDCODED_MODEL_INFERENCE_MAPPING has the model; the fixture covers every other HF cassette model
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · blocked run not counted; run once more · iter -
- Decision: David: the blocked run never reached Hugging Face, so the one try isn't spent; run the same command once more; keep the conftest Groq gpt-oss-120b mapping (881df1bab) with a PR-body line on why (2026-11-17)
- Why: Manager relayed David's yes; if it fails again for any reason, stop and report
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · no pre-push review at 881df1bab22871235e3e3019df4fa1e8137e7cfc · iter -
- Decision: Exempt delta: live-recording tests, their cassettes and the conftest Groq mapping, plus a conflict-free main merge
- Why: Exempt-delta rows 1 and 4: non-test diff vs main has the same patch-id as reviewed 9e85856c8 (c533caeef); test code/data only; established expectation is issue 10899 ThinkingPart before text and streamed thinking deltas; new cassettes, not re-records; all tests/models/test_huggingface.py pass on replay; chains from reviewed 9e85856c8 (review 1 of 3) via exempt 623870bc0 and bf88a491b
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · no pre-push review at 67395f8d807dd7a9853791682b1a60e4d53e6f62 · iter -
- Decision: Exempt delta: live-recording tests, their cassettes and the conftest Groq mapping, plus a conflict-free main merge
- Why: Exempt-delta rows 1 and 4: non-test diff vs main has the same patch-id as reviewed 9e85856c8 (c533caeef); test code/data only; established expectation is issue 10899 ThinkingPart before text and streamed thinking deltas; new cassettes, not re-records; all tests/models/test_huggingface.py pass on replay; chains from reviewed 9e85856c8 (review 1 of 3) via exempt 623870bc0 and bf88a491b
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · correction: exempt entry at 881df1bab · iter -
- Decision: The 'no pre-push review at 881df1bab' entry named the wrong sha: that commit attempt failed the whitespace hook; the exemption applies to 67395f8d807dd7a9853791682b1a60e4d53e6f62
- Why: Pre-commit trimmed whitespace-only lines in the new cassettes; parsed YAML unchanged
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · pre-push review 2 of 3 at 2b53f904bf04308e54da878f9539900ce85b659e · iter -
- Decision: reserved: dispatched, outcome pending
- Why: tree ca5c514d1df9578d07787440e091d667d98403ba; scope: follow-up since reviewed 9e85856c8 (tree ca57a21039a034dab797145a735a346927311470): live-recording tests and cassettes, conftest Groq mapping, conflict resolution against main's logprobs change (6855) in HuggingFaceStreamedResponse._map_chunk; strong tier (Opus) via claude -p from a detached policy-base checkout at e709f1df3150915a1ecbf0b759de19413c203f73
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · pre-push review 2 of 3 at 2b53f904bf04308e54da878f9539900ce85b659e · iter -
- Decision: remediated: round-trip mock docstring now states a true non-VCR reason (no live round trip recorded); merge resolution confirmed correct
- Why: tree ca5c514d1df9578d07787440e091d667d98403ba; one finding (docstring claimed replay cannot match on request body; additional_matchers=['body'] can); candidate worktree unchanged during review
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · no pre-push review at ccdf2f11db5ee763eaa717f19c07d9d505710594 · iter -
- Decision: Exempt delta: docstring-only remediation of review 2
- Why: Exempt-delta row 3: one docstring line in tests/models/test_huggingface.py, no non-comment line; chains from reviewed 2b53f904b (review 2 of 3)
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · round-trip live recording not done (deferred to manager) · iter -
- Decision: Keep the round-trip test as a mock; reviewer's preferred live round-trip recording under additional_matchers=['body'] needs another live run, which only the manager can authorize
- Why: Recording dispatch allowed one live run, now spent; round-trip rendering is unchanged by this PR (settled decision)
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · round-trip live recording: skip · iter -
- Decision: Manager: skip the live round-trip recording (net-neutral: round-trip rendering unchanged by this PR per 2026-11-15; mock docstring states the true reason); no tracking artifact (2026-11-17)
- Why: Manager verdict on the deferred entry: a defer needs a tracking artifact and this item doesn't earn one
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
2026-11-17 · metadata check at ccdf2f11db5ee763eaa717f19c07d9d505710594 · iter -
- Decision: Applied 3 of 4 corrections: verification anchors shifted +4 by the main merge, template comment removed from the decisions mirror, reasoning_content scope note moved from 'What changes for existing users' to 'Why'; rejected the missing-Supersedes claim (line present)
- Why: Fresh light-tier (Haiku) check from policy-base e709f1df3; each kept correction verified against pushing-commits-to-the-repo SKILL.md
- Source: https://github.com/pydantic/pydantic-ai/pull/10910
- Session: 4f925e21-c0bd-4acb-84d7-8a244422557e
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it. (None: responses without
reasoningare unchanged.) - PR title is fit for the release changelog.