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

Function _summarize_events_with_trace

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

Summarizes events within a trace span labeled for compaction.

(
    *,
    session: Session,
    config: EventsCompactionConfig,
    events_to_compact: list[Event],
    trigger: str,
)

Source from the content-addressed store, hash-verified

33
34
35async def _summarize_events_with_trace(
36 *,
37 session: Session,
38 config: EventsCompactionConfig,
39 events_to_compact: list[Event],
40 trigger: str,
41) -> Event | None:
42 """Summarizes events within a trace span labeled for compaction."""
43 if config.summarizer is None:
44 return None
45
46 attributes = _build_compaction_attributes(
47 session_id=session.id,
48 trigger=trigger,
49 summarizer_type=type(config.summarizer).__name__,
50 event_count=len(events_to_compact),
51 token_threshold=config.token_threshold,
52 event_retention_size=config.event_retention_size,
53 compaction_interval=config.compaction_interval,
54 overlap_size=config.overlap_size,
55 )
56
57 with tracer.start_as_current_span(f'compact_events {trigger}') as span:
58 span.set_attributes(attributes)
59 compaction_event = await config.summarizer.maybe_summarize_events(
60 events=events_to_compact
61 )
62 span.set_attributes(_build_compaction_result_attributes(compaction_event))
63 return compaction_event
64
65
66def _count_text_chars_in_content(content: types.Content | None) -> int:

Calls 4

typeFunction · 0.85

Tested by

no test coverage detected