24 lines
793 B
Python
24 lines
793 B
Python
"""
|
||
Dev Agent App 配置
|
||
使用 ADK App 包装 agent,配置上下文压缩、插件等。
|
||
"""
|
||
from google.adk.apps import App
|
||
from google.adk.apps._configs import EventsCompactionConfig # 实验性 API
|
||
from agents.luna.agent import root_agent
|
||
|
||
|
||
# 上下文压缩配置(长对话自动摘要,防止爆 context window)
|
||
compaction_config = EventsCompactionConfig(
|
||
compaction_interval=20, # 每 20 个用户轮次压缩一次
|
||
overlap_size=3, # 重叠 3 轮,保持连续性
|
||
token_threshold=50000, # token 超 50k 紧急压缩
|
||
event_retention_size=30, # 压缩时保留最近 30 条原始事件
|
||
)
|
||
|
||
# App 容器:管理 agent + 压缩配置
|
||
dev_app = App(
|
||
name="luna_agent",
|
||
root_agent=root_agent,
|
||
events_compaction_config=compaction_config,
|
||
)
|