Skip to content

Commit d899438

Browse files
refactor: wrap event compaction into a function
1 parent cbf3870 commit d899438

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

MaxKernel/auto_agent/agent.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
for the human-in-the-loop kernel generation process.
55
"""
66

7-
from google.adk.apps.app import App, EventsCompactionConfig
7+
from google.adk.apps.app import App
88

9+
from auto_agent.config import get_compaction_config
10+
from auto_agent.constants import EVENTS_COMPACTION
911
from auto_agent.subagents.autotuning.agent import autotune_agent
1012
from auto_agent.subagents.kernel_writing import (
1113
implement_kernel_agent,
@@ -32,12 +34,7 @@
3234
)
3335

3436
if EVENTS_COMPACTION:
35-
compaction_config = EventsCompactionConfig(
36-
token_threshold=200000,
37-
event_retention_size=100,
38-
compaction_interval=1,
39-
overlap_size=0,
40-
)
37+
compaction_config = get_compaction_config()
4138
else:
4239
compaction_config = None
4340

MaxKernel/auto_agent/config.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@
22

33
import os
44

5+
from google.adk.apps.app import EventsCompactionConfig
56
from google.adk.planners import BuiltInPlanner
67
from google.genai import types
78

8-
from auto_agent.constants import EVENTS_COMPACTION, TEMPERATURE, TOP_K, TOP_P
9+
from auto_agent.constants import TEMPERATURE, TOP_K, TOP_P
910

1011
# Environment variables
1112
WORKDIR = os.environ.get("WORKDIR", os.path.dirname(os.path.abspath(__file__)))
1213
TPU_VERSION = os.environ.get("TPU_VERSION", "")
1314
RAG_CORPUS = os.environ.get("RAG_CORPUS", "")
1415
INCLUDE_THOUGHTS = os.environ.get("INCLUDE_THOUGHTS", "true").lower() == "true"
1516

16-
# Events Compaction Configuration
17-
EVENTS_COMPACTION = EVENTS_COMPACTION
17+
# Set events compaction policy to avoid memory overflow
18+
def get_compaction_config():
19+
return EventsCompactionConfig(
20+
token_threshold=200000,
21+
event_retention_size=100,
22+
compaction_interval=1,
23+
overlap_size=0,
24+
)
1825

1926
# Model configuration
2027
model_config = types.GenerateContentConfig(

0 commit comments

Comments
 (0)