ADK-agents/my_agent/app.py
2026-07-30 14:29:14 +08:00

24 lines
789 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Dev Agent App 配置
使用 ADK App 包装 agent配置上下文压缩、插件等。
"""
from google.adk.apps import App
from google.adk.apps._configs import EventsCompactionConfig # 实验性 API
from my_agent.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="dev_agent",
root_agent=root_agent,
events_compaction_config=compaction_config,
)