Files
letta-ai--letta/tests/test_compaction_thresholds.py
wehub-resource-sync 4deafc5b1e
🌿 Preview Python SDK / changed-files (push) Has been cancelled
🌿 Preview Python SDK / preview-python-sdk (push) Has been cancelled
🌿 Preview TypeScript SDK / changed-files (push) Has been cancelled
🌿 Preview TypeScript SDK / preview-typescript-sdk (push) Has been cancelled
Sync Code / notify (push) Has been cancelled
Test Package Installation / test-install (3.13) (push) Has been cancelled
Test Package Installation / test-install (3.12) (push) Has been cancelled
Notify Submodule Repos / notify (push) Has been cancelled
Run Docker integration tests / test (push) Has been cancelled
🌿 Publish Docs / run (push) Has been cancelled
Test Package Installation / test-install (3.11) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:40:25 +08:00

54 lines
1.8 KiB
Python

from letta.schemas.llm_config import LLMConfig
from letta.services.summarizer.thresholds import get_compaction_trigger_threshold, is_gpt5_model_family
def test_is_gpt5_model_family_matches_raw_gpt5_names():
assert is_gpt5_model_family("gpt-5")
assert is_gpt5_model_family("gpt-5-mini")
assert is_gpt5_model_family("gpt-5.2")
def test_is_gpt5_model_family_matches_provider_prefixed_names():
assert is_gpt5_model_family("openai/gpt-5")
assert is_gpt5_model_family("openai/gpt-5.1-codex")
assert is_gpt5_model_family("azure/gpt-5-chat-latest")
def test_is_gpt5_model_family_rejects_non_gpt5_names():
assert not is_gpt5_model_family("gpt-4.1")
assert not is_gpt5_model_family("claude-sonnet-4")
assert not is_gpt5_model_family("gpt-50")
def test_get_compaction_trigger_threshold_uses_90_percent_for_gpt5():
llm_config = LLMConfig(
model="gpt-5.2",
model_endpoint_type="openai",
model_endpoint="https://api.openai.com/v1",
context_window=272000,
)
assert get_compaction_trigger_threshold(llm_config) == int(272000 * 0.9)
def test_get_compaction_trigger_threshold_uses_100_percent_for_non_gpt5():
llm_config = LLMConfig(
model="gpt-4.1",
model_endpoint_type="openai",
model_endpoint="https://api.openai.com/v1",
context_window=128000,
)
assert get_compaction_trigger_threshold(llm_config) == 128000
def test_get_compaction_trigger_threshold_force_proactive_uses_90_percent_for_non_gpt5():
llm_config = LLMConfig(
model="gpt-4.1",
model_endpoint_type="openai",
model_endpoint="https://api.openai.com/v1",
context_window=128000,
)
assert get_compaction_trigger_threshold(llm_config, force_proactive=True) == int(128000 * 0.9)