mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-11 08:38:24 +00:00
fix(responses): record every replayed turn as the path when continuing a session stored without one
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
6ec0fe1f71
commit
ba55a86042
2 changed files with 21 additions and 1 deletions
|
|
@ -357,7 +357,7 @@ class ResponsesSessionHandler:
|
|||
messages=chat_completion_message_history,
|
||||
litellm_session_id=litellm_session_id,
|
||||
instructions=_latest_replayable_instructions(proxy_server_requests),
|
||||
previous_response_ids=tuple(spend_log["request_id"] for spend_log in all_spend_logs[:replayable_turns]),
|
||||
previous_response_ids=tuple(spend_log["request_id"] for spend_log in all_spend_logs[:replayed_turns]),
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -1327,6 +1327,26 @@ async def test_the_replayed_turns_become_the_next_turns_path_to_the_root():
|
|||
assert session["previous_response_ids"] == ("root", "b2")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_turn_continuing_a_session_stored_before_paths_existed_records_every_turn_it_replayed():
|
||||
"""The legacy replay feeds the whole session to the model, so the new turn's path must name all of it."""
|
||||
fake_prisma_client: Final = _FakePrismaClient(
|
||||
results=[
|
||||
[
|
||||
_spend_log("old-1", "session", "My favorite number is 7.", "ok"),
|
||||
_spend_log("old-2", "session", "My second number is 42.", "ok"),
|
||||
]
|
||||
]
|
||||
)
|
||||
|
||||
with patch("litellm.proxy.proxy_server.prisma_client", fake_prisma_client):
|
||||
session: Final = await ResponsesSessionHandler.get_chat_completion_message_history_for_previous_response_id(
|
||||
"old-1"
|
||||
)
|
||||
|
||||
assert session["previous_response_ids"] == ("old-1", "old-2")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_session_lookup_keeps_jwt_users_and_teams_apart_when_they_share_an_empty_api_key():
|
||||
sqlite_db: Final = _SqliteBackedPrismaDB(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue