13 Commits

Author SHA1 Message Date
Liang Wu 845818be44 ci: only use --extra test for unit tests
This can fix unit test github action error by removing `--extra eval`. `--extra a2a` is not needed because it's included in `test`. All tests are still passing.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 869014318
2026-02-11 21:39:48 -08:00
George Weale 2367901ec5 chore: Upgrade to headers to 2026
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 858763407
2026-01-20 14:50:09 -08:00
Didier Durand a8f2ddd943 chore: fixing various typos
Merge https://github.com/google/adk-python/pull/4175

### Link to Issue or Description of Change

**1. Link to an existing issue (if applicable):**

N/A: just fixing typos discovered while reading the repo

**2. Or, if no issue exists, describe the change:**

No code change, just typo fixes: see commit diffs for all details

**Problem:**

Trying to improve overall repo quality

**Solution:**

Fixing typos as they get discovered

### Testing Plan

N/A

**Unit Tests:**

N/A

**Manual End-to-End (E2E) Tests:**

N/A

### Checklist

- [X] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document.
- [X] I have performed a self-review of my own code.
- [ ] I have commented my code, particularly in hard-to-understand areas.
- [ ] I have added tests that prove my fix is effective or that my feature works.
- [X] New and existing unit tests pass locally with my changes.
- [ ] I have manually tested my changes end-to-end.
- [ ] Any dependent changes have been merged and published in downstream modules.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/4175 from didier-durand:fix-typos-c 16e93ed2d9bc153fa0332ab1ae39633fcc5056e9
PiperOrigin-RevId: 858751240
2026-01-20 14:21:01 -08:00
Hangfei Lin b5f5df9fa8 fix(runners): Ensure event compaction completes by awaiting task
Fixes https://github.com/google/adk-python/issues/3174

The event compaction process, configured via `EventsCompactionConfig`, was
previously scheduled as a background task using `asyncio.create_task`.
Because Python's `asyncio.create_task` only holds a weak reference to
the created task and no strong reference was maintained by ADK, the
compaction task could be garbage-collected before it finished executing.
This resulted in event compaction failing silently or only partially
running, preventing session history from being summarized.

### Approaches Considered

Two approaches were considered to fix this:

1.  **`asyncio.create_task` + Reference:** Create the task with `create_task` and store a strong reference to it (e.g., in a `set` on the [Runner](http://_vscodecontentref_/0) instance), removing it only when complete via `task.add_done_callback()`.
    *   **Pros:** The [run_async](http://_vscodecontentref_/1) async generator finishes immediately after yielding the last agent event.
    *   **Cons:** Adds complexity to the Runner state; background task failures are silent to the [run_async](http://_vscodecontentref_/2) caller; requires enhancement to `runner.close()` to correctly manage pending tasks on shutdown.
2.  **`await`:** Directly `await` the compaction coroutine at the end of [run_async](http://_vscodecontentref_/3) after all agent events have been yielded.
    *   **Pros:** Simple to implement; ensures compaction runs to completion; failures during compaction propagate immediately to the [run_async](http://_vscodecontentref_/4) caller, making them visible and easier to debug.
    *   **Cons:** The `async for` loop iterating over [run_async](http://_vscodecontentref_/5) will not terminate until compaction finishes.

### Decision

This change implements the `await` approach. Although it means the `async for` loop takes longer to terminate when compaction occurs, it was chosen for its **simplicity and robustness**. Ensuring that compaction either succeeds or fails visibly is preferable to silent background failures.

All agent response events are yielded *before* compaction starts, so there is **no user-perceived delay in receiving the agent's answer** for the current turn.

### Integration Note for Users

Because compaction is now awaited, code consuming events via `async for event in runner.run_async(...)` will only finish iterating *after* compaction is complete (if compaction is triggered for that invocation).

If your application only needs the agent's response to proceed (e.g., displaying a message in a UI and allowing the user to reply), you can process events as they arrive and initiate the next turn without waiting for the `async for` loop to fully terminate. A new call to [run_async](http://_vscodecontentref_/6) for the next user query can be made immediately and will execute concurrently.

**Example:**

```python
async def handle_agent_turn(runner, message):
    print("Agent is thinking...")
    async for event in runner.run_async(user_id='...', session_id='...', new_message=message):
        # Stream events to UI, log, etc.
        if event.author == 'model' and event.content and event.content.parts[0].text:
            print(f"Agent response: {event.content.parts[0].text}")
            # The agent has provided a text response.
            # The application can now enable user input for the next turn,
            # even though this async for loop might not finish immediately
            # if compaction is running.
    print("Invocation complete (including compaction if any).")

# In your application:
# A new call to handle_agent_turn(runner, next_message) can be made
# as soon as the user provides the next input, without waiting for
# the previous call's generator to be exhausted.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 833885375
2025-11-18 10:57:50 -08:00
George Weale 840283228e feat!: Raise minimum Python version to 3_10
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 833363352
2025-11-17 09:02:58 -08:00
Wei Sun (Jack) f7f6837fde docs: Add python tips to AGENTS.md to assist vibe coding
Co-authored-by: Wei Sun (Jack) <weisun@google.com>
PiperOrigin-RevId: 832772144
2025-11-15 14:08:04 -08:00
Josh Soref aa1233608a chore: Fix spelling
Merge https://github.com/google/adk-python/pull/2447

This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling)

The misspellings have been reported at https://github.com/jsoref/adk-python/actions/runs/16840838898/attempts/1#summary-47711379253

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/adk-python/actions/runs/16840839269/attempts/1#summary-47711380479

Note: while I use tooling to identify errors, the tooling doesn't _actually_ provide the corrections, I'm picking them on my own. I'm a human, and I may make mistakes.

I've included a couple of changes to make CI happy. Personally, I object to CI being in a state of "random drive by person who adds a blank line in the middle of a file must fix all the preexisting bugs in the file", but that appears to be the state for this repository.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2447 from jsoref:spelling d85398e7fd154d124d477c6af6181481a01f34e0
PiperOrigin-RevId: 827629615
2025-11-03 13:33:53 -08:00
Wei Sun (Jack) 2216fe7c04 docs: Update AGENTS.md with latest development guidelines and make it general for all AI coding tools
Usage: you can create symlink to AGENTS.md with the file name required by the specific AI coding tool.

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
PiperOrigin-RevId: 825627185
2025-10-29 11:14:48 -07:00
Hangfei Lin afebb5227b chore: Update ADK Live documentation on handling audio and transcriptions
Add guidelines for saving transcriptions as session Events and audio as artifacts with references in Events.

PiperOrigin-RevId: 806424916
2025-09-12 14:20:02 -07:00
Hangfei Lin c2058f3779 chore: adk Add more documentations for ADK live feature in ADK.md
Also added commit message guidelines.

PiperOrigin-RevId: 783450329
2025-07-15 13:27:38 -07:00
Hangfei Lin 28d0ea876f feat: Add adk project overview and architecture
This explains the high-level architecture and philosophy of the ADK project.
It can also be feed into LLMs for vibe-coding.

PiperOrigin-RevId: 780178125
2025-07-07 11:00:15 -07:00
Hangfei Lin 6a39c854e0 chore: update agents.md to include versioning strategy
Adds a description for docstring and comments in the AGENTS.md and adds a section for Versioning that describes how ADK follows Semantic Versioning 2.0.0

PiperOrigin-RevId: 778667398
2025-07-02 15:51:55 -07:00
Google Team Member 37108be855 docs: Add AGENTS.md to provide relevant project context for the Gemini CLI
Including details on the ADK style guide and how to run specific tools.

PiperOrigin-RevId: 776827602
2025-06-27 21:00:54 -07:00