mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-05 07:37:50 +00:00
* test(e2e): add the Codex file edit and long session rows The file edit row has Codex change a random value into config.txt with the patch tool and checks the file on disk. The long session row has it follow a chain of random file names one cat at a time. new_workspace now returns the resolved path, because Codex reports patched files by their real path (/private/var on macOS). * test(e2e): make the Codex long session prove every earlier command output reached the model * test(e2e): Codex auto-compaction through LiteLLM (#49389) * test(e2e): add the Codex auto-compaction row Codex reads a random value, compacts through the gateway with its remote compaction forced on, and is asked for the value after the file holding it is deleted. The row reads the compaction from the thread's rollout file and marks Claude on Bedrock as a strict expected failure, since the Responses-to-chat bridge ignores the compaction_trigger item * refactor(e2e): validate Codex rollout lines with the models directly
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""The compactions Codex recorded in a thread's rollout file, `CODEX_HOME/sessions/**/rollout-*-<thread id>.jsonl`.
|
|
|
|
`codex exec --json` prints no event for a compaction, so the rollout is the only place it shows. Each line is
|
|
`{"timestamp", "type", "payload"}` (`codex-rs/history/src/rollout_payload.rs`) and only `compacted` lines are read.
|
|
A remote compaction is one whose replacement history carries the provider's `compaction` item, while a local one
|
|
replaces the history with a summary Codex wrote itself.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Final
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
_COMPACTED: Final = "compacted"
|
|
_PROVIDER_COMPACTION_ITEM: Final = "compaction"
|
|
|
|
|
|
class _Frozen(BaseModel):
|
|
model_config = ConfigDict(frozen=True)
|
|
|
|
|
|
class _Line(_Frozen):
|
|
type: str
|
|
payload: object = None
|
|
|
|
|
|
class _HistoryItem(_Frozen):
|
|
type: str
|
|
|
|
|
|
class _CompactedPayload(_Frozen):
|
|
replacement_history: tuple[_HistoryItem, ...] | None = None
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class Compaction:
|
|
remote: bool
|
|
|
|
|
|
def rollout_compactions(rollout: str) -> tuple[Compaction, ...]:
|
|
lines: Final = tuple(_Line.model_validate_json(line) for line in rollout.splitlines() if line.strip())
|
|
return tuple(_compaction(line.payload) for line in lines if line.type == _COMPACTED)
|
|
|
|
|
|
def _compaction(payload: object) -> Compaction:
|
|
history: Final = _CompactedPayload.model_validate(payload).replacement_history or ()
|
|
return Compaction(remote=any(item.type == _PROVIDER_COMPACTION_ITEM for item in history))
|