Skip to content

Add ADK compaction flushing persistence#179

Merged
gvdongen merged 3 commits intomainfrom
adk_flush_compaction
Mar 13, 2026
Merged

Add ADK compaction flushing persistence#179
gvdongen merged 3 commits intomainfrom
adk_flush_compaction

Conversation

@gvdongen
Copy link
Contributor

@gvdongen gvdongen commented Mar 13, 2026

This PR makes sure that the ADK integration supports event compaction:

  • RestateEventsSummarizer: to wrap LLM summarization calls in durable steps
  • Flushing compaction events in append_event to Restate

Example usage

agent = Agent(
    model="gemini-2.5-flash",
    name="assistant",
    instruction="You are a helpful assistant. Be concise and helpful.",
)
app = App(
    name=APP_NAME, 
    root_agent=agent, 
    plugins=[RestatePlugin()],
    events_compaction_config=EventsCompactionConfig(
        summarizer=RestateEventSummarizer.from_llm(llm=agent.canonical_model),
        compaction_interval=3,  
        overlap_size=1         
    ),
)
runner = Runner(app=app, session_service=RestateSessionService())

chat = restate.VirtualObject("Chat")


@chat.handler()
async def message(ctx: restate.ObjectContext, req: ChatMessage) -> str | None:
    events = runner.run_async(
        user_id=ctx.key(),
        session_id=req.session_id,
        new_message=Content(role="user", parts=[Part.from_text(text=req.message)]),
    )
    return await parse_agent_response(events)

Fixes #178

@gvdongen gvdongen requested a review from igalshilman March 13, 2026 01:16
@github-actions
Copy link

github-actions bot commented Mar 13, 2026

Test Results

  7 files  ±0    7 suites  ±0   4m 9s ⏱️ +20s
 49 tests ±0   49 ✅ ±0  0 💤 ±0  0 ❌ ±0 
210 runs  ±0  210 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 70cc997. ± Comparison against base commit 9437df9.

♻️ This comment has been updated with latest results.

@gvdongen gvdongen merged commit 975adc1 into main Mar 13, 2026
8 checks passed
@gvdongen gvdongen deleted the adk_flush_compaction branch March 13, 2026 16:02
@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RestatePlugin: compaction event not persisted — flush_session_state called before compaction runs

2 participants