instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Create documentation for each function signature
#!/usr/bin/env python3 # Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
--- +++ @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Cache Performance Experiments for ADK Context Caching + +This script runs two experiments to compare caching performance: +A. Gemini 2.0 Flash: Cache enabled vs disabled (explicit c...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/cache_analysis/run_cache_experiments.py
Add missing documentation to my Python functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -37,17 +37,28 @@ def get_api_call_count() -> int: + """ + Returns the total number of API calls made since the last reset. + + Returns: + int: The global count of API calls. + """ with _counter_lock: return _api_call_count def reset_api_call_count() -> None: + """Resets the global ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/adk_stale_agent/utils.py
Add docstrings for production code
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -22,6 +22,14 @@ def roll_die(sides: int, tool_context: ToolContext) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ result = random.randint(1, sides) if not ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/callbacks/agent.py
Replace inline comments with docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -21,6 +21,7 @@ def reimburse(purpose: str, amount: float) -> str: + """Reimburse the amount of money to the employee.""" return { 'status': 'ok', } @@ -29,6 +30,7 @@ def ask_for_approval( purpose: str, amount: float, tool_context: ToolContext ) -> dict[str, Any]: + """Ask for approva...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/a2a_human_in_loop/remote_a2a/human_in_loop/agent.py
Generate descriptive docstrings automatically
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -45,6 +45,14 @@ def list_open_issues(issue_count: int) -> dict[str, Any]: + """List most recent `issue_count` number of open issues in the repo. + + Args: + issue_count: number of issues to return + + Returns: + The status of this request, with a list of issues when successful. + """ url = f...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/adk_issue_formatting_agent/agent.py
Add return value explanations in docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -38,6 +38,7 @@ async def fetch_specific_issue_details(issue_number: int): + """Fetches details for a single issue if it needs triaging.""" url = f"{GITHUB_BASE_URL}/repos/{OWNER}/{REPO}/issues/{issue_number}" print(f"Fetching details for specific issue: {url}") @@ -91,6 +92,7 @@ async def call_a...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/adk_triaging_agent/main.py
Generate consistent docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -11,6 +11,17 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +"""Sales Data Assistant Agent demonstrating context offloading with artifacts. + +This agent simulates querying ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/context_offloading_with_artifact/agent.py
Expand my code with proper documentation strings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""ADK utils for a LLMAgent interacting with a simulation environment.""" from __future__ import annotations @@ -37,6 +38,7 @@ class EnvResponse(Protocol): + """Environment resp...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/gepa/adk_agent.py
Can you add docstrings to this Python file?
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -20,10 +20,26 @@ def roll_die(sides: int) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ return random.randint(1, sides) async def check_prime(nums: list[...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/hello_world_anthropic/agent.py
Improve my code by adding docstrings
import random from google.adk.tools.tool_context import ToolContext def roll_die(sides: int, tool_context: ToolContext) -> int: result = random.randint(1, sides) if not 'rolls' in tool_context.state: tool_context.state['rolls'] = [] tool_context.state['rolls'] = tool_context.state['rolls'] + [result] re...
--- +++ @@ -4,6 +4,14 @@ def roll_die(sides: int, tool_context: ToolContext) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ result = random.randint(1, sides) if not 'r...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/core_callback_config/tools.py
Improve my code by adding docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -20,6 +20,14 @@ def roll_die(sides: int, tool_context: ToolContext) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ result = random.randint(1, sides) if "rol...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/hello_world_apigeellm/agent.py
Write docstrings for this repository
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Sample demonstrating CrewAI tool with **kwargs parameter handling. + +This sample shows how CrewaiTool correctly passes arbitrary parameters +through **kwargs, which is a common patte...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/crewai_tool_kwargs/agent.py
Add docstrings including usage examples
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data science agent, with a custom code executor that enables Japanese fonts.""" from __future__ import annotations @@ -44,6 +45,7 @@ def _load_font_file(font_url: str, font_fi...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/custom_code_execution/agent.py
Add concise docstrings to each method
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Happy path test for CrewAI tool with **kwargs parameter handling. + +This demonstrates that CrewaiTool correctly passes arbitrary parameters +through **kwargs to the underlying CrewAI...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/crewai_tool_kwargs/main.py
Add standardized docstrings across the file
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -20,6 +20,14 @@ def roll_die(sides: int, tool_context: ToolContext) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ result = random.randint(1, sides) if not ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/hello_world/agent.py
Add docstrings for internal functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -22,6 +22,14 @@ def roll_die(sides: int, tool_context: ToolContext) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ result = random.randint(1, sides) if not ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/fields_planner/agent.py
Add inline docstrings for readability
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +"""Dummy service implementations for testing.""" from __future__ import annotations @@ -28,8 +29,15 @@ c...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/dummy_services.py
Add docstrings with type hints explained
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Defines utility for GEPA experiments.""" import logging from typing import Callable @@ -23,8 +24,10 @@ class FilterInferenceWarnings(logging.Filter): + """Filters out Vertex i...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/gepa/utils.py
Write docstrings for data processing functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Allows to run an ADK agent implementation with a Tau-bench environment. + +Note that Tau-bench needs to be installed to run this module. To install +Tau-bench you can follow the steps...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/gepa/tau_bench_agent.py
Add docstrings including usage examples
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -22,6 +22,7 @@ # --- Roll Die Sub-Agent --- def roll_die(sides: int) -> int: + """Roll a die and return the rolled result.""" return random.randint(1, sides) @@ -46,6 +47,7 @@ # --- Prime Check Sub-Agent --- def check_prime(nums: list[int]) -> str: + """Check if a given list of numbers are pri...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/hello_world_ma/agent.py
Help me comply with documentation standards
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -30,6 +30,14 @@ def roll_die(sides: int, tool_context: ToolContext) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ result = random.randint(1, sides) if not ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/hello_world_app/agent.py
Write docstrings for backend logic
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -21,6 +21,14 @@ def roll_die(sides: int, tool_context: ToolContext) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ result = random.randint(1, sides) if not ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/history_management/agent.py
Fully document this Python code with docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -21,10 +21,26 @@ def roll_die(sides: int) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ return random.randint(1, sides) async def check_prime(nums: list[...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/hello_world_gemma/agent.py
Add docstrings to make code maintainable
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +"""Tools for Vote Taker Agent.""" from datetime import datetime import os @@ -76,6 +77,15 @@ def get_voting_o...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/gepa/voter_agent/tools.py
Generate descriptive docstrings automatically
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Library for rating agent trajectories.""" from __future__ import annotations @@ -29,6 +30,14 @@ def parse_rubric_validation_response( rubric_val_response: str, ) -> dict[str...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/gepa/rater_lib.py
Add docstrings for internal functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Runs Tau-bench.""" from __future__ import annotations @@ -52,6 +53,23 @@ system_instruction: str | None = None, rater: rater_lib.Rater | None = None, ) -> list[EnvRunRes...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/gepa/experiment.py
Write docstrings for data processing functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -20,10 +20,26 @@ def roll_die(sides: int) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ return random.randint(1, sides) async def check_prime(nums: list[...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/hello_world_litellm/agent.py
Turn comments into proper docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -21,6 +21,7 @@ def reimburse(purpose: str, amount: float) -> str: + """Reimburse the amount of money to the employee.""" return { 'status': 'ok', } @@ -29,6 +30,7 @@ def ask_for_approval( purpose: str, amount: float, tool_context: ToolContext ) -> dict[str, Any]: + """Ask for approva...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/human_in_loop/agent.py
Help me add docstrings to my project
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Agent definition for testing the Interactions API integration. + +NOTE: The Interactions API does NOT support mixing custom function calling tools +with built-in tools in the same age...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/interactions_api/agent.py
Add standardized docstrings across the file
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,29 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Main script for testing the Interactions API integration. + +This script tests the following features: +1. Basic text generation +2. Google Search tool (via bypass_multi_tools_limit) ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/interactions_api/main.py
Create docstrings for API functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -21,10 +21,26 @@ def roll_die(sides: int) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ return random.randint(1, sides) def check_prime(number: int) -> s...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/hello_world_litellm_add_function_to_prompt/agent.py
Write docstrings for algorithm functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -23,10 +23,26 @@ def roll_die(sides: int) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ return random.randint(1, sides) async def check_prime(nums: list[...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/hello_world_gemma3_ollama/agent.py
Provide docstrings following PEP 257
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -27,6 +27,7 @@ class InlineJsonToolClient(LiteLLMClient): + """LiteLLM client that emits inline JSON tool calls for testing.""" async def acompletion(self, model, messages, tools, **kwargs): del tools, kwargs # Only needed for API parity. @@ -85,6 +86,7 @@ def _find_last_role( messages: ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/litellm_inline_tool_call/agent.py
Write docstrings for algorithm functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Runs the LiteLLM streaming sample with SSE enabled.""" from __future__ import annotations @@ -37,6 +38,7 @@ session_id: str, prompt: str, ) -> None: + """Runs one promp...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/litellm_streaming/main.py
Include argument descriptions in docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -19,10 +19,26 @@ def roll_die(sides: int) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ return random.randint(1, sides) def check_prime(numbers: list[int...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/hello_world_ollama/agent.py
Write proper docstrings for these functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -22,16 +22,19 @@ def reimburse(amount: int, tool_context: ToolContext) -> str: + """Reimburse the employee for the given amount.""" return {'status': 'ok'} async def confirmation_threshold( amount: int, tool_context: ToolContext ) -> bool: + """Returns true if the amount is greater than 1...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/human_tool_confirmation/agent.py
Generate descriptive docstrings automatically
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Sample agent showing LiteLLM structured output support.""" from __future__ import annotations @@ -22,6 +23,7 @@ class CitySummary(BaseModel): + """Simple structure used to ve...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/litellm_structured_output/agent.py
Document functions with clear intent
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -23,6 +23,7 @@ # 1. Define the data structure for the pizza order. class PizzaOrder(BaseModel): + """A data class to hold the details of a pizza order.""" size: str crust: str @@ -31,14 +32,17 @@ # 2. Define tools for the order intake agent. def get_available_sizes() -> list[str]: + """Return...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/json_passing_agent/agent.py
Add docstrings to improve code quality
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -23,6 +23,7 @@ # --- Roll Die Sub-Agent --- def roll_die(sides: int) -> int: + """Roll a die and return the rolled result.""" return random.randint(1, sides) @@ -61,6 +62,7 @@ # --- Prime Check Sub-Agent --- def check_prime(nums: list[int]) -> str: + """Check if a given list of numbers are pri...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/live_bidi_streaming_multi_agent/agent.py
Write clean docstrings for readability
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -20,6 +20,14 @@ def roll_die(sides: int, tool_context: ToolContext) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ result = random.randint(1, sides) if not ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/live_bidi_streaming_single_agent/agent.py
Improve documentation using docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -22,6 +22,7 @@ async def monitor_stock_price(stock_symbol: str) -> AsyncGenerator[str, None]: + """This function will monitor the price for the given stock_symbol in a continuous, streaming and asynchronously way.""" print(f"Start monitor stock price for {stock_symbol}!") # Let's mock stock pric...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/live_bidi_streaming_tools_agent/agent.py
Create documentation for each function signature
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Sample agent demonstrating log probability usage. + +This agent shows how to access log probabilities from language model responses. +The after_model_callback appends confidence infor...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/logprobs/agent.py
Provide docstrings following PEP 257
import random from google.adk.examples.example import Example from google.adk.tools.example_tool import ExampleTool from google.genai import types def roll_die(sides: int) -> int: return random.randint(1, sides) def check_prime(nums: list[int]) -> str: primes = set() for number in nums: number = int(numb...
--- +++ @@ -6,10 +6,12 @@ def roll_die(sides: int) -> int: + """Roll a die and return the rolled result.""" return random.randint(1, sides) def check_prime(nums: list[int]) -> str: + """Check if a given list of numbers are prime.""" primes = set() for number in nums: number = int(number) @@ -69...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/multi_agent_llm_config/__init__.py
Write docstrings for data processing functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,36 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Sample agent demonstrating MCP progress callback feature. + +This sample shows how to use the progress_callback parameter in McpToolset +to receive progress notifications from MCP ser...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/mcp_progress_callback_agent/agent.py
Provide clean and structured docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -25,6 +25,12 @@ def get_weather(location: str, tool_context: ToolContext) -> Dict[str, Any]: + """Get weather information for a location. + Args: + location: The city or location to get weather for. + Returns: + A dictionary containing weather information. + """ # Simulate weather data te...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/live_tool_callbacks_agent/agent.py
Document classes and their methods
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -19,8 +19,10 @@ class CountInvocationPlugin(BasePlugin): + """A custom plugin that counts agent and tool invocations.""" def __init__(self) -> None: + """Initialize the plugin with counters.""" super().__init__(name="count_invocation") self.agent_count: int = 0 self.tool_count: in...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/plugin_basic/count_plugin.py
Document classes and their methods
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Mock MCP server that sends progress notifications. + +This server demonstrates how MCP servers can send progress updates +during long-running tool execution. + +Run this server direct...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/mcp_progress_callback_agent/mock_progress_server.py
Add docstrings for internal functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -26,6 +26,7 @@ # Add a tool to read file contents @mcp.tool(description="Read contents of a file") def read_file(filepath: str) -> str: + """Read and return the contents of a file.""" with open(filepath, "r") as f: return f.read() @@ -33,12 +34,14 @@ # Add a tool to list directory contents @mcp...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/mcp_sse_agent/filesystem_server.py
Write docstrings for backend logic
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -27,6 +27,7 @@ # Add a tool to read file contents @mcp.tool(description="Read contents of a file") def read_file(filepath: str) -> str: + """Read and return the contents of a file.""" with open(filepath, "r") as f: return f.read() @@ -34,12 +35,14 @@ # Add a tool to list directory contents @mcp...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/mcp_streamablehttp_agent/filesystem_server.py
Add docstrings to incomplete code
# Copyright 2025 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""MCP Server that requires OAuth Bearer token for both tool listing and calling. + +This server validates the Authorization header on every request including: +- Tool listing (list_tool...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/mcp_toolset_auth/oauth_mcp_server.py
Add docstrings to meet PEP guidelines
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -19,10 +19,26 @@ def roll_die(sides: int) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ return random.randint(1, sides) async def check_prime(nums: list[...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/migrate_session_db/agent.py
Write docstrings describing each step
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -41,6 +41,17 @@ def run_migrations_offline() -> None: + """Run migrations in 'offline' mode. + + This configures the context with just a URL + and not an Engine, though an Engine is acceptable + here as well. By skipping the Engine creation + we don't even need a DBAPI to be available. + + Calls t...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/migrate_session_db/sample-output/alembic/env.py
Add detailed documentation for each class
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -16,6 +16,14 @@ def get_weather(city: str) -> dict: + """Retrieves the current weather report for a specified city. + + Args: + city (str): The name of the city for which to retrieve the weather report. + + Returns: + dict: status and result or error msg. + """ if city.lower() == "new yo...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/quickstart/agent.py
Can you add docstrings to this Python file?
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Example demonstrating PostgreSQL session persistence with DatabaseSessionService.""" import asyncio import os @@ -27,6 +28,7 @@ async def main(): + """Main function demonstrat...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/postgres_session_service/main.py
Add docstrings to my Python code
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Weather Assistant Agent. + +This agent provides weather information for cities worldwide. +It demonstrates OAuth2 client credentials flow transparently +through AuthenticatedFunctionT...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/oauth2_client_credentials/agent.py
Generate docstrings for exported functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Sample agent demonstrating output_schema with tools feature. + +This agent shows how to use structured output (output_schema) alongside +other tools. Previously, this combination was ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/output_schema_with_tools/agent.py
Generate docstrings with examples
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Example agent demonstrating the use of SkillToolset.""" import pathlib @@ -25,6 +26,7 @@ class GetTimezoneTool(BaseTool): + """A tool to get the timezone for a given location...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/skills_agent/agent.py
Add docstrings to improve code quality
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
--- +++ @@ -1,3 +1,8 @@+"""WeatherAssistant Agent main script. + +This script demonstrates OAuth2 client credentials flow using a practical +weather assistant agent with AuthenticatedFunctionTool. +""" # Copyright 2026 Google LLC # @@ -31,6 +36,7 @@ def process_arguments(): + """Parses command-line arguments."...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/oauth2_client_credentials/main.py
Add concise docstrings to each method
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
--- +++ @@ -1,3 +1,4 @@+"""Static non-text content sample agent main script.""" # Copyright 2026 Google LLC # @@ -33,6 +34,7 @@ async def call_agent_async( runner, user_id: str, session_id: str, prompt: str ) -> str: + """Helper function to call agent and return final response.""" from google.adk.agents.r...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/static_non_text_content/main.py
Add docstrings that explain logic
#!/usr/bin/env python3 # Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
--- +++ @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +"""Simple test script for Pydantic argument agent.""" # Copyright 2026 Google LLC # @@ -30,6 +31,7 @@ async def call_agent_async(runner, user_id, session_id, prompt): + """Helper function to call the agent and return response.""" content = types.Content( ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/pydantic_argument/main.py
Generate docstrings for exported functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -56,6 +56,13 @@ # call right after a function call that request auth # see https://github.com/google/adk-python/issues/1944 for details def redact_event_content(event_content: str) -> str: + """Redact confidential information in the calendar event content + Args: + event_content: the content of the ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/oauth_calendar_agent/agent.py
Add well-formatted docstrings
# Copyright 2025 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Sample agent demonstrating DebugLoggingPlugin usage. + +This sample shows how to use the DebugLoggingPlugin to capture complete +debug information (LLM requests/responses, tool calls,...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/plugin_debug_logging/agent.py
Add return value explanations in docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -28,6 +28,14 @@ def roll_die(sides: int, tool_context: ToolContext) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ result = random.randint(1, sides) if not ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/plugin_reflect_tool_retry/hallucinating_func_name/agent.py
Provide clean and structured docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Sample agent for testing parallel function calling.""" import asyncio import time @@ -22,6 +23,14 @@ async def get_weather(city: str, tool_context: ToolContext) -> dict: + """...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/parallel_functions/agent.py
Expand my code with proper documentation strings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Simple agent demonstrating Pydantic model arguments in tools.""" from typing import Optional from typing import Union @@ -22,6 +23,7 @@ class UserProfile(pydantic.BaseModel): +...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/pydantic_argument/agent.py
Create docstrings for all classes and functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -18,17 +18,20 @@ async def update_state(tool_context: ToolContext, key: str, value: str) -> dict: + """Updates a state value.""" tool_context.state[key] = value return {"status": f"Updated state '{key}' to '{value}'"} async def load_state(tool_context: ToolContext, key: str) -> dict: + """Lo...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/rewind_session/agent.py
Help me write clear docstrings
#!/usr/bin/env python3 # Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
--- +++ @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +"""Simple test script for Rewind Session agent.""" # Copyright 2026 Google LLC # @@ -40,6 +41,7 @@ def highlight(text: str) -> str: + """Adds color highlights to tool responses and agent text.""" text = str(text) return ( text.replace("'red'", f"'{CO...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/rewind_session/main.py
Add docstrings for utility scripts
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Sample agent demonstrating PostgreSQL session persistence.""" from datetime import datetime from datetime import timezone @@ -20,6 +21,11 @@ def get_current_time() -> str: + "...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/postgres_session_service/agent.py
Add missing documentation to my Python functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -21,6 +21,7 @@ # --- Roll Die Sub-Agent --- def roll_die(sides: int) -> int: + """Roll a die and return the rolled result.""" return random.randint(1, sides) @@ -45,6 +46,7 @@ def check_prime(nums: list[int]) -> str: + """Check if a given list of numbers are prime.""" primes = set() for...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/simple_sequential_agent/agent.py
Write docstrings for utility functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -97,6 +97,14 @@ settings: SpannerToolSettings, tool_context: ToolContext, ): + """Counts the total number of rows for a specified table. + + Args: + table_name: The name of the table for which to count rows. + + Returns: + The total number of rows in the table. + """ # Example of a...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/spanner/agent.py
Write docstrings that follow conventions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
--- +++ @@ -1,3 +1,8 @@+"""Digital Pet Agent. + +This agent demonstrates static instructions for context caching with a digital +pet that has different moods based on feeding time stored in session state. +""" # Copyright 2026 Google LLC # @@ -113,6 +118,18 @@ def eat(tool_context: ToolContext) -> str: + """Fe...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/static_instruction/agent.py
Add docstrings that explain inputs and outputs
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Static non-text content sample agent demonstrating static instructions with non-text parts.""" import base64 @@ -52,6 +53,12 @@ def create_static_instruction_with_file_upload(...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/static_non_text_content/agent.py
Add docstrings explaining edge cases
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
--- +++ @@ -1,3 +1,8 @@+"""Bingo Digital Pet main script. + +This script demonstrates static instruction functionality through a digital pet +that has different moods based on feeding time stored in session state. +""" # Copyright 2026 Google LLC # @@ -32,6 +37,7 @@ async def call_agent_async( runner, user_id,...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/static_instruction/main.py
Annotate my code with docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -22,6 +22,14 @@ def roll_die(sides: int, tool_context: ToolContext) -> int: + """Roll a die and return the rolled result. + + Args: + sides: The integer number of sides the die has. + + Returns: + An integer of the result of rolling the die. + """ result = random.randint(1, sides) if not ...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/telemetry/agent.py
Generate descriptive docstrings automatically
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +"""Interceptor that injects the new agent version extension.""" from __future__ import annotations @@ -34,6 ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/a2a/agent/interceptors/new_integration_extension.py
Add professional docstrings to my codebase
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -27,8 +27,10 @@ def before_agent_callback_check_relevance( agent_name: str, ) -> BeforeAgentCallback: + """Callback to check if the state is relevant before executing the agent.""" def callback(callback_context: CallbackContext) -> Optional[types.Content]: + """Check if the state is relevant."...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/workflow_triage/execution_agent.py
Write docstrings for this repository
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -129,6 +129,7 @@ a2a_parts: List[A2APart], part_converter: A2APartToGenAIPartConverter = convert_a2a_part_to_genai_part, ) -> tuple[List[genai_types.Part], set[str]]: + """Converts a list of A2A parts to a list of ADK parts.""" output_parts = [] long_running_function_ids = set() @@ -173,6 ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/a2a/converters/to_adk_event.py
Add docstrings explaining edge cases
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -56,6 +56,17 @@ @a2a_experimental class A2aAgentExecutor(AgentExecutor): + """An AgentExecutor that runs an ADK Agent against an A2A request and + + publishes updates to an event queue. + + Args: + runner: The runner to use for the agent. + config: The config to use for the executor. + use_leg...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/a2a/executor/a2a_agent_executor.py
Add minimal docstrings for each function
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data science agent that uses Vertex AI code interpreter.""" from google.adk.agents.llm_agent import Agent from google.adk.code_executors.vertex_ai_code_executor import VertexAiCo...
https://raw.githubusercontent.com/google/adk-python/HEAD/contributing/samples/vertex_code_execution/agent.py
Replace inline comments with docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Configuration for A2A agents.""" from __future__ import annotations @@ -41,6 +42,7 @@ class ParametersConfig(BaseModel): + """Configuration for the parameters passed to the A...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/a2a/agent/config.py
Can you add docstrings to this Python file?
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Provides instructions to an agent by fetching prompts from an MCP server.""" from __future__ import annotations @@ -29,6 +30,7 @@ class McpInstructionProvider(InstructionProvi...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/agents/mcp_instruction_provider.py
Write docstrings for backend logic
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -24,6 +24,21 @@ @experimental(FeatureName.AGENT_CONFIG) class ContextCacheConfig(BaseModel): + """Configuration for context caching across all agents in an app. + + This configuration enables and controls context caching behavior for + all LLM agents in an app. When this config is present on an app, co...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/agents/context_cache_config.py
Insert docstrings into my code
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Utilities for A2A agents.""" from __future__ import annotations @@ -33,6 +34,7 @@ ctx: InvocationContext, a2a_request: A2AMessage, ) -> tuple[Union[A2AMessage, Event], P...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/a2a/agent/utils.py
Replace inline comments with docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Loop agent implementation.""" from __future__ import annotations @@ -39,6 +40,7 @@ @experimental(FeatureName.AGENT_STATE) class LoopAgentState(BaseAgentState): + """State for ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/agents/loop_agent.py
Help me document legacy Python code
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -88,6 +88,18 @@ event: Event, part_converter: GenAIPartToA2APartConverter = convert_genai_part_to_a2a_part, ) -> Optional[List[A2APart]]: + """Converts an ADK event to an A2A parts list. + + Args: + event: The ADK event to convert. + part_converter: The function to convert GenAI part to A2A...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/a2a/converters/from_adk_event.py
Create Google-style docstrings for my code
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -24,6 +24,7 @@ class LiveRequest(BaseModel): + """Request send to live agents.""" model_config = ConfigDict(ser_json_bytes='base64', val_json_bytes='base64') """The pydantic model config.""" @@ -57,6 +58,7 @@ class LiveRequestQueue: + """Queue used to send LiveRequest in a live(bidirectiona...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/agents/live_request_queue.py
Add missing documentation to my Python functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +"""Utility functions for handling artifact URIs.""" from __future__ import annotations @@ -22,6 +23,7 @@ ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/artifacts/artifact_util.py
Write docstrings for data processing functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -30,6 +30,7 @@ def _count_text_chars_in_content(content: types.Content | None) -> int: + """Returns the number of text characters in a content object.""" total_chars = 0 if content and content.parts: for part in content.parts: @@ -41,6 +42,7 @@ def _valid_compactions( events: list[Event]...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/apps/compaction.py
Write clean docstrings for readability
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Auth provider registry.""" from __future__ import annotations @@ -23,6 +24,7 @@ @experimental(FeatureName.PLUGGABLE_AUTH) class AuthProviderRegistry: + """Registry for auth pr...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/auth/auth_provider_registry.py
Write documentation strings for class attributes
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -28,6 +28,7 @@ def validate_app_name(name: str) -> None: + """Ensures the provided application name is safe and intuitive.""" if not name.isidentifier(): raise ValueError( f"Invalid app name '{name}': must be a valid identifier consisting of" @@ -39,6 +40,18 @@ @experimental class Re...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/apps/app.py
Create Google-style docstrings for my code
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -36,6 +36,10 @@ class AuthHandler: + """A handler that handles the auth flow in Agent Development Kit to help + orchestrate the credential request and response flow (e.g. OAuth flow) + This class should only be used by Agent Development Kit. + """ def __init__(self, auth_config: AuthConfig): ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/auth/auth_handler.py
Add minimal docstrings for each function
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -26,8 +26,18 @@ @experimental(FeatureName.PLUGGABLE_AUTH) class BaseAuthProvider(ABC): + """Abstract base class for custom authentication providers.""" @abstractmethod async def get_auth_credential( self, auth_config: AuthConfig, context: CallbackContext - ) -> AuthCredential | None:+ ) ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/auth/base_auth_provider.py
Add concise docstrings to each method
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -43,6 +43,25 @@ auth_responses: dict[str, Any], state: State, ) -> set[str]: + """Store auth credentials and return original function call IDs to resume. + + Scans session events for ``adk_request_credential`` function calls whose + IDs are in *auth_fc_ids*, extracts ``credential_key`` from thei...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/auth/auth_preprocessor.py
Write docstrings describing functionality
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -93,18 +93,33 @@ @a2a_experimental class AgentCardResolutionError(Exception): + """Raised when agent card resolution fails.""" pass @a2a_experimental class A2AClientError(Exception): + """Raised when A2A client operations fail.""" pass @a2a_experimental class RemoteA2aAgent(BaseAge...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/agents/remote_a2a_agent.py
Generate docstrings for exported functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Credential exchanger registry.""" from __future__ import annotations @@ -25,6 +26,7 @@ @experimental class CredentialExchangerRegistry: + """Registry for credential exchanger ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/auth/exchanger/credential_exchanger_registry.py
Add docstrings for production code
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -40,6 +40,42 @@ @experimental class CredentialManager: + """Manages authentication credentials through a structured workflow. + + The CredentialManager orchestrates the complete lifecycle of authentication + credentials, from initial loading to final preparation for use. It provides + a centralized in...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/auth/credential_manager.py
Write docstrings for algorithm functions
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Parallel agent implementation.""" from __future__ import annotations @@ -36,6 +37,7 @@ sub_agent: BaseAgent, invocation_context: InvocationContext, ) -> InvocationContex...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/agents/parallel_agent.py
Improve my code by adding docstrings
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -37,28 +37,35 @@ @property def user_content(self) -> Optional[types.Content]: + """The user content that started this invocation. READONLY field.""" return self._invocation_context.user_content @property def invocation_id(self) -> str: + """The current invocation id.""" return ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/agents/readonly_context.py
Fill in missing docstrings in my code
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -24,9 +24,24 @@ @experimental class BaseEventsSummarizer(abc.ABC): + """Base interface for compacting events.""" @abc.abstractmethod async def maybe_summarize_events( self, *, events: list[Event] ) -> Optional[Event]: - raise NotImplementedError()+ """Compact a list of events into...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/apps/base_events_summarizer.py
Generate consistent documentation across files
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
--- +++ @@ -47,6 +47,7 @@ class OAuthGrantType(str, Enum): + """Represents the OAuth2 flow (or grant type).""" CLIENT_CREDENTIALS = "client_credentials" AUTHORIZATION_CODE = "authorization_code" @@ -55,6 +56,7 @@ @staticmethod def from_flow(flow: OAuthFlows) -> "OAuthGrantType": + """Converts an ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/auth/auth_schemes.py