Repository navigation
feat: configure assistant reasoning history for compatible providers #41050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
jibanez-staticduo
wants to merge
38
commits into
BerriAI:main
from
jibanez-staticduo:litellm_forward_reasoning_content
Closed
Changes from 5 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
30bee8a
feat(hosted_vllm): opt in to forwarding assistant reasoning content
jibanez-staticduo 8a82ea7
fix(hosted_vllm): isolate forwarded reasoning in response caches
jibanez-staticduo 9e47c58
feat: configure historical assistant reasoning field
jibanez-staticduo 101537c
fix: preserve Python 3.12 OpenAPI snapshot formatting
jibanez-staticduo c84c73b
fix: preserve reasoning field on partial model updates
jibanez-staticduo a1db7d6
fix: preserve reasoning forwarding on partial updates
jibanez-staticduo 624f2f9
fix: support encrypted reasoning field storage
jibanez-staticduo 115f4fd
fix: validate reasoning field before chat dispatch
jibanez-staticduo a1c4035
merge: sync upstream and preserve model management tests
jibanez-staticduo a590abf
test: annotate reasoning history test parameters
jibanez-staticduo 4c79d96
merge: preserve reasoning normalization with prompt cache ordering
jibanez-staticduo 2b9268c
merge: bring reasoning-history PR onto current upstream main
jibanez-staticduo d3a79d8
merge: sync reasoning-history PR onto upstream c19ce71bcd
jibanez-staticduo c52edca
Merge remote-tracking branch 'upstream/main' into litellm_forward_rea…
jibanez-staticduo 7a6c2ac
test(types): register reasoning transport options in the owned inventory
jibanez-staticduo eac8c95
Merge remote-tracking branch 'upstream/main' into litellm_forward_rea…
jibanez-staticduo 6716494
test(ci): drop the repeated UNIT_FLAG key in the shard paths test
jibanez-staticduo 04ea8f4
merge: sync upstream with the relocated unit test tree
jibanez-staticduo b39fd06
merge: sync upstream through the client pool refactor
jibanez-staticduo 1e7d04a
refactor(router): declare the reasoning transport options on the para…
jibanez-staticduo 8897879
test(catalog): validate ultrafast pricing fields in the strict schema
jibanez-staticduo e5098f6
chore(reasoning): remove narrative comments flagged in review
jibanez-staticduo 82ef0b9
test(interactions): follow operation schemas and declared path parame…
jibanez-staticduo c7837be
chore: merge upstream main into reasoning history support
jibanez-staticduo 2a7abe8
test: remove duplicate catalog fields after upstream merge
jibanez-staticduo 5b13a21
fix: synchronize trace routes and generated API types
jibanez-staticduo 70fce7d
merge: synchronize upstream and repair batch request fixtures
jibanez-staticduo 7b4df9a
test: harden batches mock scope and MCP cancellation deadline handshake
jibanez-staticduo 1625735
Merge branch 'codex/pr41050-ci-test-timing' into litellm_forward_reas…
jibanez-staticduo b273b97
style: apply ruff format to MCP client test tree file
jibanez-staticduo 0be9a3d
Merge upstream main f553c80cd3 into litellm_forward_reasoning_content
jibanez-staticduo 0b630f4
fix: update vulnerable GitPython and Tornado dependencies
jibanez-staticduo 9738840
fix(rust_bridge): name NativeTraceStorage.query stub parameter as the…
jibanez-staticduo b95c3dc
Revert "fix: update vulnerable GitPython and Tornado dependencies"
jibanez-staticduo 57434ae
Merge upstream main 424bfd8758 into litellm_forward_reasoning_content
jibanez-staticduo 8a6eee4
style: ruff format the merged OpenAPI compliance test file
jibanez-staticduo 9c32039
test(traces): align native tests with named read queries
jibanez-staticduo 9f6bfb2
chore: merge upstream main into reasoning history
jibanez-staticduo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| from collections.abc import Mapping, Sequence | ||
| from copy import deepcopy | ||
| from types import MappingProxyType | ||
| from typing import ( | ||
| Final, | ||
| cast, # noqa: TID251 # Preserves arbitrary provider fields without lossy TypedDict validation. | ||
| ) | ||
|
|
||
| from litellm.types.llms.openai import AllMessageValues | ||
|
|
||
|
|
||
| def normalize_reasoning_content( | ||
| messages: Sequence[AllMessageValues], *, forward: bool = True | ||
| ) -> list[AllMessageValues]: # mutable-ok: provider request contract | ||
| def normalize_message(message: AllMessageValues) -> AllMessageValues: | ||
| if message["role"] != "assistant": | ||
| return message | ||
| history: Final[Mapping[str, object]] = message | ||
| reasoning: Final = ( | ||
| history.get("reasoning") if history.get("reasoning") is not None else history.get("reasoning_content") | ||
| ) | ||
| normalized: Final[Mapping[str, object]] = MappingProxyType( | ||
| { | ||
| **MappingProxyType( | ||
| {key: value for key, value in history.items() if key not in ("reasoning", "reasoning_content")} | ||
| ), | ||
| **( | ||
| MappingProxyType({"reasoning": reasoning}) | ||
| if forward and reasoning is not None | ||
| else MappingProxyType({}) | ||
| ), | ||
| } | ||
| ) | ||
| result: Final = dict(normalized) # mutable-ok: provider request contract | ||
| return cast(AllMessageValues, result) # cast-ok: only optional reasoning keys change | ||
|
|
||
| return [normalize_message(message) for message in deepcopy(messages)] # mutable-ok: provider request contract |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.