ソースを参照

框架:将上下文压缩调整为八成触发三成目标

把默认压缩触发点从硬预算 75% 调整为 80%,压缩目标从 50% 收紧到 30%,并同步真实 token 预算测试断言。
SamLee 10 時間 前
コミット
ddc660341d
2 ファイル変更4 行追加4 行削除
  1. 2 2
      agent/agent/trace/compaction.py
  2. 2 2
      agent/tests/test_context_budget.py

+ 2 - 2
agent/agent/trace/compaction.py

@@ -113,8 +113,8 @@ class CompressionConfig:
     """压缩配置"""
     max_tokens: int = 0            # 最大 token 数(0 = 自动:context_window * 0.5)
     threshold_ratio: float = 0.5       # 触发压缩的阈值 = context_window 的比例
-    trigger_ratio: float = 0.75
-    target_ratio: float = 0.50
+    trigger_ratio: float = 0.80
+    target_ratio: float = 0.30
     fallback_safety_factor: float = 1.25
     keep_recent_messages: int = 10     # Level 1 中始终保留最近 N 条消息
     max_messages: int = 0              # 最大消息数(超过此数量触发压缩,0 = 禁用,默认禁用)

+ 2 - 2
agent/tests/test_context_budget.py

@@ -53,8 +53,8 @@ def test_prompt_measurement_includes_tools_and_provider_calibration():
     assert measured.estimated_tokens > raw.estimated_tokens
     assert factor == 2
     assert calibrated.calibrated_tokens == measured.estimated_tokens * 2
-    assert calibrated.trigger_tokens == 75_000
-    assert calibrated.target_tokens == 50_000
+    assert calibrated.trigger_tokens == 80_000
+    assert calibrated.target_tokens == 30_000
 
 
 @pytest.mark.asyncio