Skip to content

Commit 2f75baa

Browse files
authored
Merge branch 'main' into skill-script-utf8-output
2 parents 637bb86 + 757ef22 commit 2f75baa

177 files changed

Lines changed: 8243 additions & 8842 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.3.0"
2+
".": "2.4.0"
33
}

.github/release-please-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@
5757
]
5858
}
5959
},
60-
"last-release-sha": "0cb4c814928f579bfbac9b9e1f95669e4304e089"
60+
"last-release-sha": "44d747ed5eaf543b5b8d22e0088f8a7c7eeee846"
6161
}

CHANGELOG.md

Lines changed: 180 additions & 0 deletions
Large diffs are not rendered by default.

src/google/adk/apps/compaction.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from __future__ import annotations
1616

1717
import logging
18+
from typing import AsyncGenerator
1819

1920
from google.genai import types
2021

@@ -443,7 +444,7 @@ async def _run_compaction_for_sliding_window(
443444
session_service: BaseSessionService,
444445
*,
445446
skip_token_compaction: bool = False,
446-
):
447+
) -> AsyncGenerator[Event, None]:
447448
"""Runs compaction for SlidingWindowCompactor.
448449
449450
This method implements the sliding window compaction logic. It determines
@@ -521,30 +522,35 @@ async def _run_compaction_for_sliding_window(
521522
Args:
522523
app: The application instance.
523524
session: The session containing events to compact.
524-
session_service: The session service for appending events.
525+
session_service: The session service, used by the token-threshold fallback.
525526
skip_token_compaction: Whether to skip token-threshold compaction.
527+
528+
Yields:
529+
The sliding-window compaction event, if one is produced. The caller (the
530+
runner loop) is responsible for appending it to the session, so that
531+
persistence of this event stays at the runtime's synchronization point.
526532
"""
527533
events = session.events
528534
if not events:
529-
return None
535+
return
530536

531537
config = app.events_compaction_config
532538
if config is None:
533-
return None
539+
return
534540

535541
# Prefer token-threshold compaction if configured and triggered.
536542
if not skip_token_compaction and _has_token_threshold_config(config):
537543
token_compacted = await _run_compaction_for_token_threshold(
538544
app, session, session_service
539545
)
540546
if token_compacted:
541-
return None
547+
return
542548

543549
if not _has_sliding_window_config(config):
544-
return None
550+
return
545551

546552
if config.compaction_interval is None or config.overlap_size is None:
547-
return None
553+
return
548554

549555
# Find the last compaction event and its range.
550556
last_compacted_end_timestamp = 0.0
@@ -573,7 +579,7 @@ async def _run_compaction_for_sliding_window(
573579
]
574580

575581
if len(new_invocation_ids) < config.compaction_interval:
576-
return None # Not enough new invocations to trigger compaction.
582+
return # Not enough new invocations to trigger compaction.
577583

578584
# Determine the range of invocations to compact.
579585
# The end of the compaction range is the last of the new invocations.
@@ -613,20 +619,20 @@ async def _run_compaction_for_sliding_window(
613619
events_to_compact = _longest_self_contained_prefix(events_to_compact)
614620

615621
if not events_to_compact:
616-
return None
622+
return
617623

618624
if app.root_agent is None:
619-
return None
625+
return
620626
_ensure_compaction_summarizer(config=config, agent=app.root_agent)
621627
if config.summarizer is None:
622-
return None
628+
return
623629

624630
compaction_event = await _summarize_events_with_trace(
625631
session=session,
626632
config=config,
627633
events_to_compact=events_to_compact,
628634
trigger='sliding_window',
629635
)
630-
if compaction_event:
631-
await session_service.append_event(session=session, event=compaction_event)
632636
logger.debug('Event compactor finished.')
637+
if compaction_event:
638+
yield compaction_event

src/google/adk/cli/browser/assets/audio-processor.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2026 Google LLC
2+
* Copyright 2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
1717
class AudioProcessor extends AudioWorkletProcessor {
1818
constructor() {
1919
super();
20-
this.targetSampleRate = 22000; // Change to your desired rate
20+
this.targetSampleRate = 16000; // Live API expects 16 kHz PCM input
2121
this.originalSampleRate = sampleRate; // Browser's sample rate
2222
this.resampleRatio = this.originalSampleRate / this.targetSampleRate;
2323
}
@@ -26,7 +26,7 @@ class AudioProcessor extends AudioWorkletProcessor {
2626
const input = inputs[0];
2727
if (input.length > 0) {
2828
let audioData = input[0]; // Get first channel's data
29-
29+
3030
if (this.resampleRatio !== 1) {
3131
audioData = this.resample(audioData);
3232
}
@@ -40,9 +40,15 @@ class AudioProcessor extends AudioWorkletProcessor {
4040
const newLength = Math.round(audioData.length / this.resampleRatio);
4141
const resampled = new Float32Array(newLength);
4242

43+
// Linear interpolation resampling (higher quality than nearest neighbor)
44+
const lastIndex = audioData.length - 1;
4345
for (let i = 0; i < newLength; i++) {
44-
const srcIndex = Math.floor(i * this.resampleRatio);
45-
resampled[i] = audioData[srcIndex]; // Nearest neighbor resampling
46+
const srcPos = i * this.resampleRatio;
47+
const srcIndex = Math.floor(srcPos);
48+
const nextIndex = Math.min(srcIndex + 1, lastIndex);
49+
const frac = srcPos - srcIndex;
50+
resampled[i] =
51+
audioData[srcIndex] * (1 - frac) + audioData[nextIndex] * frac;
4652
}
4753
return resampled;
4854
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"backendUrl": ""
3-
}
3+
}

src/google/adk/cli/browser/chunk-27SWUPRL.js

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/adk/cli/browser/chunk-2DLZXFEQ.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)