MCPcopy Create free account
hub / github.com/google/adk-python / _run_compaction_for_token_threshold

Function _run_compaction_for_token_threshold

src/google/adk/apps/compaction.py:420–437  ·  view source on GitHub ↗

Runs post-invocation compaction based on a token threshold. If triggered, this compacts older raw events and keeps the last `event_retention_size` raw events un-compacted.

(
    app: App, session: Session, session_service: BaseSessionService
)

Source from the content-addressed store, hash-verified

418
419
420async def _run_compaction_for_token_threshold(
421 app: App, session: Session, session_service: BaseSessionService
422):
423 """Runs post-invocation compaction based on a token threshold.
424
425 If triggered, this compacts older raw events and keeps the last
426 `event_retention_size` raw events un-compacted.
427 """
428 if app.root_agent is None:
429 return None
430 return await _run_compaction_for_token_threshold_config(
431 config=app.events_compaction_config,
432 session=session,
433 session_service=session_service,
434 agent=app.root_agent,
435 agent_name='',
436 current_branch=None,
437 )
438
439
440async def _run_compaction_for_sliding_window(

Callers 1

Tested by

no test coverage detected