Skip to content

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

@stefanjemuovic

Description

@stefanjemuovic

Bug Description

When using EventsCompactionConfig with RestatePlugin +
RestateSessionService,
the compaction event is never persisted to Restate K/V. Compaction fires an LLM
summarization call as expected, but the result is silently discarded every time,
regardless of the configured compaction_interval.

Root Cause

In google/adk/runners.py, the execution order is:

  1. _exec_with_plugin(...) runs and closes
    after_run_callbackflush_session_state() → session persisted to Restate
    K/V
  2. _run_compaction_for_sliding_window(...) runs
    → calls session_service.append_event(session, compaction_event)
    → appends to in-memory session only — no second flush

flush_session_state is called before compaction, so the compaction event is
never
written to Restate K/V. On the next invocation, get_session() loads a session
without the compaction event, so last_compacted_end_timestamp is always 0.0
and all historical invocations are treated as "new" on every run.

Observed Behavior

Compaction triggers on schedule per compaction_interval, makes a real LLM
summarization call, but the resulting compaction event is never saved. On the
next invocation, the same events are compacted again — burning LLM credits with
no effect. The session grows unboundedly as if compaction was never configured.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions