instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Add docstrings to clarify complex 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...
--- +++ @@ -16,7 +16,13 @@ class AlreadyExistsError(Exception): + """Represents an error that occurs when an entity already exists.""" def __init__(self, message="The resource already exists."): + """Initializes the AlreadyExistsError exception. + + Args: + message (str): An optional custom messa...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/errors/already_exists_error.py
Generate documentation strings for clarity
# 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,7 @@ class ConversationScenario(EvalBaseModel): + """Scenario for a conversation between a simulated user and the Agent under test.""" starting_prompt: str """Starting prompt for the conversation. @@ -66,7 +67,11 @@ class ConversationScenarios(EvalBaseModel): + """A simple contain...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/conversation_scenarios.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, softw...
--- +++ @@ -36,6 +36,7 @@ class CustomMetricConfig(BaseModel): + """Configuration for a custom metric.""" model_config = ConfigDict( alias_generator=alias_generators.to_camel, @@ -59,6 +60,7 @@ @model_validator(mode="after") def check_code_config_args(self) -> "CustomMetricConfig": + """Check...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/eval_config.py
Add detailed docstrings explaining 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,6 +26,7 @@ class UserBehavior(BaseModel): + """Container for the behavior of a persona.""" name: str = Field(description="Name of the UserBehavior") @@ -53,13 +54,16 @@ ) def get_behavior_instructions_str(self): + """Returns a string version of the violation rubrics.""" return ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/simulation/user_simulator_personas.py
Auto-generate documentation strings for this 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...
--- +++ @@ -31,6 +31,7 @@ class PerInvocationResult(BaseModel): + """Metric evaluation score per invocation.""" actual_invocation: Invocation expected_invocation: Optional[Invocation] = None @@ -54,6 +55,7 @@ class Evaluator(ABC): + """A metrics evaluator interface.""" criterion_type: ClassVar[ty...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/evaluator.py
Document helper functions 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, softw...
--- +++ @@ -73,6 +73,7 @@ class JudgeModelOptions(EvalBaseModel): + """Options for an eval metric's judge model.""" judge_model: str = Field( default="gemini-2.5-flash", @@ -102,6 +103,7 @@ class BaseCriterion(BaseModel): + """Base criterion to use for an Eval Metric.""" model_config = Config...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/eval_metrics.py
Add docstrings to existing 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 @@ class IntermediateData(EvalBaseModel): + """Container for intermediate data that an agent would generate as it responds with a final answer.""" tool_uses: list[genai_types.FunctionCall] = [] """Tool use trajectory in chronological order.""" @@ -50,6 +51,14 @@ class InvocationE...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/eval_case.py
Add docstrings to existing 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, softw...
--- +++ @@ -22,6 +22,7 @@ class RubricContent(EvalBaseModel): + """The content of a rubric.""" text_property: Optional[str] = Field( description=( @@ -32,6 +33,7 @@ class Rubric(EvalBaseModel): + """This class represents a single Rubric.""" rubric_id: str = Field( description="Unique i...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/eval_rubrics.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...
--- +++ @@ -47,6 +47,19 @@ @experimental class LlmAsJudge(Evaluator): + """Evaluator based on a LLM. + + It is meant to be extended by specific auto-raters for different evaluation + tasks: + - Provide the prompt template, and implement format_auto_rater_prompt to + format the auto-rater prompt for a give...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/llm_as_judge.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...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Base class for agent loaders.""" from __future__ import annotations @@ -25,12 +26,15 @@ class BaseAgentLoader(ABC): + """Abstract base class for agent loaders.""" @abstr...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/cli/utils/base_agent_loader.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...
--- +++ @@ -33,6 +33,7 @@ class BaseUserSimulatorConfig(BaseModel): + """Base class for configurations pertaining to user simulator.""" model_config = ConfigDict( alias_generator=alias_generators.to_camel, @@ -42,6 +43,7 @@ class Status(enum.Enum): + """The resulting status of get_next_user_messag...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/simulation/user_simulator.py
Document all public functions 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...
--- +++ @@ -40,8 +40,15 @@ class GcsEvalSetsManager(EvalSetsManager): + """An EvalSetsManager that stores eval sets in a GCS bucket.""" def __init__(self, bucket_name: str, **kwargs): + """Initializes the GcsEvalSetsManager. + + Args: + bucket_name: The name of the bucket to use. + **kwargs: K...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/gcs_eval_sets_manager.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...
--- +++ @@ -80,6 +80,14 @@ def _parse_critique(response: str) -> Label: + """Parses the judge model critique and extracts the final label. + + Args: + response: model response + + Returns: + The extracted label, either VALID, INVALID, or NOT_FOUND. + """ # Regex matching the label field in the response...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/final_response_match_v2.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...
--- +++ @@ -33,6 +33,7 @@ @experimental class StaticUserSimulator(UserSimulator): + """A UserSimulator that returns a static list of user messages.""" def __init__(self, *, static_conversation: StaticConversation): super().__init__( @@ -46,6 +47,16 @@ self, events: list[Event], ) -> NextUs...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/simulation/static_user_simulator.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...
--- +++ @@ -214,18 +214,21 @@ @dataclasses.dataclass(frozen=True) class EvaluationStep: + """The context and natural language response to be evaluated at a step.""" context: str nl_response: str def _parse_sentences(response_text: str) -> list[str]: + """Parses sentences from LLM response.""" retur...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/hallucinations_v1.py
Create documentation strings for testing 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...
--- +++ @@ -29,6 +29,11 @@ class Event(LlmResponse): + """Represents an event in a conversation between agents and users. + + It is used to store the content of the conversation, as well as the actions + taken by the agents like function calls, etc. + """ model_config = ConfigDict( extra='forbid', @...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/events/event.py
Add structured docstrings to improve clarity
# 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,7 @@ class LlmBackedUserSimulatorConfig(BaseUserSimulatorConfig): + """Contains configurations required by an LLM backed user simulator.""" model: str = Field( default="gemini-2.5-flash", @@ -108,6 +109,7 @@ @experimental class LlmBackedUserSimulator(UserSimulator): + """A User...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/simulation/llm_backed_user_simulator.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...
--- +++ @@ -22,6 +22,7 @@ class TrajectoryEvaluatorMetricInfoProvider(MetricInfoProvider): + """Metric info provider for TrajectoryEvaluator.""" def get_metric_info(self) -> MetricInfo: return MetricInfo( @@ -40,11 +41,13 @@ class ResponseEvaluatorMetricInfoProvider(MetricInfoProvider): + """Metric ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/metric_info_providers.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...
--- +++ @@ -48,6 +48,7 @@ def _convert_invocation_to_pydantic_schema( invocation_in_json_format: dict[str, Any], ) -> Invocation: + """Converts an invocation from old json format to new Pydantic Schema.""" query = invocation_in_json_format["query"] reference = invocation_in_json_format.get("reference", "")...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/local_eval_sets_manager.py
Write docstrings including parameters and return values
# 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...
--- +++ @@ -51,10 +51,21 @@ @experimental class MetricEvaluatorRegistry: + """A registry for metric Evaluators.""" _registry: dict[str, tuple[type[Evaluator], MetricInfo]] = {} def get_evaluator(self, eval_metric: EvalMetric) -> Evaluator: + """Returns an Evaluator for the given metric. + + A new in...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/metric_evaluator_registry.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...
--- +++ @@ -32,6 +32,7 @@ @enum.unique class Label(enum.Enum): + """Labels for auto rater response.""" TRUE = "true" INVALID = "invalid" @@ -58,6 +59,14 @@ def get_average_rubric_score( rubric_scores: list[RubricScore], ) -> Optional[float]: + """Returns a single score value from the given list of ru...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/llm_as_judge_utils.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...
--- +++ @@ -23,6 +23,7 @@ class EvalSetResultsManager(ABC): + """An interface to manage Eval Set Results.""" @abstractmethod def save_eval_set_result( @@ -31,14 +32,21 @@ eval_set_id: str, eval_case_results: list[EvalCaseResult], ) -> None: + """Creates and saves a new EvalSetResult give...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/eval_set_results_manager.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...
--- +++ @@ -34,8 +34,15 @@ class GcsEvalSetResultsManager(EvalSetResultsManager): + """An EvalSetResultsManager that stores eval results in a GCS bucket.""" def __init__(self, bucket_name: str, **kwargs): + """Initializes the GcsEvalSetsManager. + + Args: + bucket_name: The name of the bucket to ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/gcs_eval_set_results_manager.py
Generate helpful docstrings for debugging
# 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,8 @@ @experimental class UserSimulatorProvider: + """Provides a UserSimulator instance per EvalCase, mixing configuration data + from the EvalConfig with per-EvalCase conversation data.""" def __init__( self, @@ -39,6 +41,20 @@ self._user_simulator_config = user_simulator_confi...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/simulation/user_simulator_provider.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...
--- +++ @@ -40,6 +40,7 @@ class RubricResponse(EvalBaseModel): + """Internal data model to represent a rubric's response from the auto-rater.""" property_text: Optional[str] = None rationale: Optional[str] = None @@ -47,9 +48,11 @@ class AutoRaterResponseParser(abc.ABC): + """An interface for parsing ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/rubric_based_evaluator.py
Add well-formatted 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...
--- +++ @@ -78,6 +78,19 @@ llm_response: LlmResponse, model_response_event: Event, ) -> Event: + """Finalize and build the model response event from LLM response. + + Merges the LLM response data into the model response event and + populates function call IDs and long-running tool information. + + Args: +...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/base_llm_flow.py
Write reusable 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...
--- +++ @@ -106,6 +106,7 @@ def is_valid_user_simulator_template( template_str: str, required_params: list[str] ) -> bool: + """Checks if the given template_str is a valid jinja template.""" from jinja2 import exceptions from jinja2 import meta from jinja2 import StrictUndefined @@ -138,6 +139,7 @@ ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/simulation/llm_backed_user_simulator_prompts.py
Add docstrings to improve collaboration
# 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...
--- +++ @@ -46,6 +46,14 @@ def _parse_llm_response(response: str) -> Label: + """Parses the LLM response and extracts the final label. + + Args: + response: LLM response. + + Returns: + The extracted label, either VALID, INVALID, or NOT_FOUND. + """ # Regex matching the label field in the response. ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/simulation/per_turn_user_simulator_quality_v1.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...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Handles output schema when tools are also present.""" from __future__ import annotations @@ -29,6 +30,7 @@ class _OutputSchemaRequestProcessor(BaseLlmRequestProcessor): + """...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/_output_schema_processor.py
Add docstrings to clarify complex 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...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Handles agent transfer for LLM flow.""" from __future__ import annotations @@ -34,6 +35,7 @@ class _AgentTransferLlmRequestProcessor(BaseLlmRequestProcessor): + """Agent tran...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/agent_transfer.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...
--- +++ @@ -36,6 +36,29 @@ class TrajectoryEvaluator(Evaluator): + """Evaluates tool use trajectories for accuracy. + + This evaluator compares the sequence of tools called by the agent against a + list of expected calls and computes an average score based on one of the match + types: `EXACT`, `IN_ORDER`, or `A...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/trajectory_evaluator.py
Add docstrings that explain purpose and usage
# 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 FeatureName(str, Enum): + """Feature names.""" AGENT_CONFIG = "AGENT_CONFIG" AGENT_STATE = "AGENT_STATE" @@ -53,6 +54,14 @@ class FeatureStage(Enum): + """Feature lifecycle stages. + + Attributes: + WIP: Work in progress, not functioning completely. ADK internal dev...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/features/_feature_registry.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...
--- +++ @@ -206,6 +206,7 @@ def _get_latest_turn_user_simulator_quality_prompt_template( user_persona: Optional[UserPersona] = None, ) -> str: + """Returns the appropriate prompt for user simulator quality""" if user_persona is None: return _LATEST_TURN_USER_SIMULATOR_EVALUATOR_PROMPT_TEMPLATE return ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/simulation/per_turn_user_simulator_quality_prompts.py
Create docstrings for each class 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...
--- +++ @@ -36,6 +36,17 @@ feature_stage: FeatureStage, default_on: bool = False, ) -> Callable[[T], T]: + """Decorator for experimental features. + + Args: + feature_name: The name of the feature to decorate. + feature_stage: The stage of the feature. + default_on: Whether the feature is enabled b...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/features/_feature_decorator.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...
--- +++ @@ -50,6 +50,14 @@ class _VertexAiEvalFacade(Evaluator): + """Simple facade for Vertex Gen AI Eval SDK. + + Vertex Gen AI Eval SDK exposes quite a few metrics that are valuable for + agentic evals. This class helps us to access those metrics. + + Using this class requires a GCP project. Please set GOOGL...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/vertex_ai_eval_facade.py
Add docstrings to clarify complex 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...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Defines the processor interface used for BaseLlmFlow.""" from __future__ import annotations @@ -29,20 +30,24 @@ class BaseLlmRequestProcessor(ABC): + """Base class for LLM re...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/_base_llm_processor.py
Write Python docstrings for this snippet
# 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...
--- +++ @@ -31,6 +31,25 @@ class _RequestIntercepterPlugin(BasePlugin): + """A plugin that intercepts requests that are made to the model and couples them with the model response. + + NOTE: This implementation is intended for eval systems internal usage. Do not + take direct dependency on it. + + Context behind...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/evaluation/request_intercepter_plugin.py
Add verbose 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...
--- +++ @@ -30,6 +30,27 @@ class LangchainTool(FunctionTool): + """Adapter class that wraps a Langchain tool for use with ADK. + + This adapter converts Langchain tools into a format compatible with Google's + generative AI function calling interface. It preserves the tool's name, + description, and functionali...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/integrations/langchain/langchain_tool.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...
--- +++ @@ -23,6 +23,7 @@ class AudioTranscriber: + """Transcribes audio using Google Cloud Speech-to-Text.""" def __init__(self, init_client=False): if init_client: @@ -31,6 +32,18 @@ def transcribe_file( self, invocation_context: InvocationContext ) -> list[genai_types.Content]: + """Tra...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/audio_transcriber.py
Add documentation for all 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,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Handles basic information to build the LLM request.""" from __future__ import annotations @@ -32,6 +33,15 @@ invocation_context: InvocationContext, llm_request: LlmReques...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/basic.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...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Handles Code Execution related logic.""" from __future__ import annotations @@ -53,6 +54,7 @@ @dataclasses.dataclass class DataFileUtil: + """A structure that contains a data ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/_code_execution.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...
--- +++ @@ -30,8 +30,14 @@ class AudioCacheManager: + """Manages audio caching and flushing for live streaming flows.""" def __init__(self, config: AudioCacheConfig | None = None): + """Initialize the audio cache manager. + + Args: + config: Configuration for audio caching behavior. + """ s...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/audio_cache_manager.py
Create docstrings for each class 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...
--- +++ @@ -35,6 +35,7 @@ class _ContentLlmRequestProcessor(BaseLlmRequestProcessor): + """Builds the contents for the LLM request.""" @override async def run_async( @@ -88,6 +89,7 @@ def _rearrange_events_for_async_function_responses_in_history( events: list[Event], ) -> list[Event]: + """Rearrange...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/contents.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...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Request processor that runs token-threshold event compaction.""" from __future__ import annotations @@ -29,6 +30,7 @@ class CompactionRequestProcessor(BaseLlmRequestProcessor)...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/compaction.py
Add docstrings for better understanding
# 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...
--- +++ @@ -72,6 +72,7 @@ def _supports_generate_memories_metadata() -> bool: + """Returns whether installed Vertex SDK supports config.metadata.""" try: from vertexai._genai.types import common as vertex_common_types except ImportError: @@ -83,6 +84,7 @@ def _supports_create_memory_metadata() -> bo...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/memory/vertex_ai_memory_bank_service.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,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Context cache processor for LLM requests.""" from __future__ import annotations @@ -32,10 +33,26 @@ class ContextCacheRequestProcessor(BaseLlmRequestProcessor): + """Request ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/context_cache_processor.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...
--- +++ @@ -26,6 +26,27 @@ class LlmResponse(BaseModel): + """LLM response class that provides the first candidate response from the + + model if available. Otherwise, returns error code and message. + + Attributes: + content: The content of the response. + grounding_metadata: The grounding metadata of the...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/llm_response.py
Create docstrings for reusable components
# 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. +"""Manages context cache lifecycle for Gemini models.""" from __future__ import annotations @@ -37,13 +38,37 @@ @experimental class GeminiContextCacheManager: + """Manages contex...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/gemini_context_cache_manager.py
Document helper functions 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...
--- +++ @@ -29,12 +29,19 @@ class TranscriptionManager: + """Manages transcription events for live streaming flows.""" async def handle_input_transcription( self, invocation_context: InvocationContext, transcription: types.Transcription, ) -> None: + """Handle user input transcripti...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/transcription_manager.py
Add verbose 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. +"""Gives the agent identity from the framework.""" from __future__ import annotations @@ -26,6 +27,7 @@ class _IdentityLlmRequestProcessor(BaseLlmRequestProcessor): + """Gives t...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/identity.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...
--- +++ @@ -30,6 +30,7 @@ class BaseLlm(BaseModel): + """The BaseLLM class.""" model_config = ConfigDict( # This allows us to use arbitrary types in the model. E.g. PIL.Image. @@ -42,18 +43,118 @@ @classmethod def supported_models(cls) -> list[str]: + """Returns a list of supported models in ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/base_llm.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...
--- +++ @@ -23,6 +23,34 @@ class CacheMetadata(BaseModel): + """Metadata for context cache associated with LLM responses. + + This class stores cache identification, usage tracking, and lifecycle + information for a particular cache instance. It can be in two states: + + 1. Active cache state: cache_name is set...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/cache_metadata.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...
--- +++ @@ -39,6 +39,12 @@ def _parse_tool_confirmation(response: dict[str, Any]) -> ToolConfirmation: + """Parse ToolConfirmation from a function response dict. + + Handles both the direct dict format and the ADK client's + ``{'response': json_string}`` wrapper format. + + """ if response and len(response.v...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/request_confirmation.py
Add docstrings to existing 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. +"""Implementation of single flow.""" from __future__ import annotations @@ -35,6 +36,7 @@ def _create_request_processors(): + """Create the standard request processor list for a...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/single_flow.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...
--- +++ @@ -47,6 +47,7 @@ def _log_eval_summary(eval_results: list[EvalCaseResult]): + """Logs a summary of eval results.""" num_pass, num_fail, num_other = 0, 0, 0 for eval_result in eval_results: eval_result: EvalCaseResult @@ -65,6 +66,7 @@ def extract_tool_call_data( intermediate_data: Intermed...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/optimization/local_eval_sampler.py
Help me write clear 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,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. +"""Interactions API processor for LLM requests.""" from __future__ import annotations @@ -29,10 +30,23 @@ ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/interactions_processor.py
Write beginner-friendly 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. +"""Handles instructions and global instructions for LLM flow.""" from __future__ import annotations @@ -35,6 +36,18 @@ agent: 'LlmAgent', invocation_context: 'InvocationCont...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/instructions.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...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Handles function calling for LLM flow.""" from __future__ import annotations @@ -68,6 +69,11 @@ def _is_live_request_queue_annotation(param: inspect.Parameter) -> bool: + """...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/flows/llm_flows/functions.py
Add structured docstrings to improve clarity
# 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,11 @@ class CrewaiTool(FunctionTool): + """Use this class to wrap a CrewAI tool. + + If the original tool name and description are not suitable, you can override + them in the constructor. + """ tool: CrewaiBaseTool """The wrapped CrewAI tool.""" @@ -58,6 +63,16 @@ async def run_a...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/integrations/crewai/crewai_tool.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...
--- +++ @@ -29,6 +29,7 @@ class ApiRegistry: + """Registry that provides McpToolsets for MCP servers registered in API Registry.""" def __init__( self, @@ -38,6 +39,14 @@ Callable[[ReadonlyContext], dict[str, str]] | None ) = None, ): + """Initialize the API Registry. + + Args...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/integrations/api_registry/api_registry.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...
--- +++ @@ -36,6 +36,7 @@ class VertexAiRagMemoryService(BaseMemoryService): + """A memory service that uses Vertex AI RAG for storage and retrieval.""" def __init__( self, @@ -43,6 +44,16 @@ similarity_top_k: Optional[int] = None, vector_distance_threshold: float = 10, ): + """Initi...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/memory/vertex_ai_rag_memory_service.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...
--- +++ @@ -62,8 +62,14 @@ class ApigeeLlm(Gemini): + """A BaseLlm implementation for calling Apigee proxy. + + Attributes: + model: The name of the Gemini model. + """ class ApiType(str, enum.Enum): + """The supported API types for Apigee LLM.""" UNKNOWN = 'unknown' CHAT_COMPLETIONS = 'ch...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/apigee_llm.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...
--- +++ @@ -30,6 +30,13 @@ class BuiltInPlanner(BasePlanner): + """The built-in planner that uses model's built-in thinking features. + + Attributes: + thinking_config: Config for model built-in thinking features. An error + will be returned if this field is set for models that don't support + ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/planners/built_in_planner.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...
--- +++ @@ -23,24 +23,59 @@ class BaseLlmConnection: + """The base class for a live model connection.""" @abstractmethod async def send_history(self, history: list[types.Content]): + """Sends the conversation history to the model. + + You call this method right after setting up the model connection. ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/base_llm_connection.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...
--- +++ @@ -32,17 +32,34 @@ class SearchMemoryResponse(BaseModel): + """Represents the response from a memory search. + + Attributes: + memories: A list of memory entries that relate to the search query. + """ memories: list[MemoryEntry] = Field(default_factory=list) class BaseMemoryService(ABC): ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/memory/base_memory_service.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,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Client library for interacting with the Google Cloud Agent Registry within ADK.""" from __future__ import annotations @@ -48,6 +49,7 @@ class _ProtocolType(str, Enum): + """S...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/integrations/agent_registry/agent_registry.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...
--- +++ @@ -38,10 +38,18 @@ def _extract_words_lower(text: str) -> set[str]: + """Extracts words from a string and converts them to lowercase.""" return set([word.lower() for word in re.findall(r'[A-Za-z]+', text)]) class InMemoryMemoryService(BaseMemoryService): + """An in-memory memory service for proto...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/memory/in_memory_memory_service.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...
--- +++ @@ -36,6 +36,7 @@ class GeminiLlmConnection(BaseLlmConnection): + """The Gemini model connection.""" def __init__( self, @@ -50,6 +51,15 @@ self._model_version = model_version async def send_history(self, history: list[types.Content]): + """Sends the conversation history to the gemi...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/gemini_llm_connection.py
Document helper functions 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...
--- +++ @@ -42,6 +42,7 @@ class GEPARootAgentPromptOptimizerConfig(BaseModel): + """Contains configuration options required by the GEPARootAgentPromptOptimizer.""" optimizer_model: str = Field( default="gemini-2.5-flash", @@ -79,6 +80,7 @@ class GEPARootAgentPromptOptimizerResult(OptimizerResult[Ag...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/optimization/gepa_root_agent_prompt_optimizer.py
Create documentation strings for testing 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...
--- +++ @@ -59,6 +59,7 @@ class _ResourceExhaustedError(ClientError): + """Represents a resources exhausted error received from the Model.""" def __init__( self, @@ -80,6 +81,13 @@ class Gemini(BaseLlm): + """Integration for Gemini models. + + Attributes: + model: The name of the Gemini model....
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/google_llm.py
Add docstrings for better understanding
# 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. +"""Anthropic integration for Claude models.""" from __future__ import annotations @@ -53,6 +54,7 @@ @dataclasses.dataclass class _ToolUseAccumulator: + """Accumulates streamed to...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/anthropic_llm.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...
--- +++ @@ -39,10 +39,19 @@ class GemmaFunctionCallingMixin: + """Mixin providing function calling support for Gemma models. + + Gemma models don't have native function calling support, so this mixin + provides the logic to: + 1. Convert function declarations to system instruction prompts + 2. Convert function...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/gemma_llm.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...
--- +++ @@ -32,6 +32,7 @@ def _find_tool_with_function_declarations( llm_request: LlmRequest, ) -> Optional[types.Tool]: + """Find an existing Tool with function_declarations in the LlmRequest.""" # TODO: add individual tool with declaration and merge in google_llm.py if not llm_request.config or not llm_r...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/llm_request.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...
--- +++ @@ -12,6 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Utilities for the Interactions API integration. + +This module provides both conversion utilities and the main entry point +for generating content via the Interactions API. It include...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/interactions_utils.py
Write docstrings including parameters and return values
# 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...
--- +++ @@ -32,6 +32,18 @@ def _adjust_split_index_to_avoid_orphaned_function_responses( contents: Sequence[types.Content], split_index: int ) -> int: + """Moves `split_index` left until function calls/responses stay paired. + + When truncating context, we must avoid keeping a `function_response` while + dropp...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/plugins/context_filter_plugin.py
Generate helpful docstrings for debugging
# 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. +"""The registry class for model.""" from __future__ import annotations @@ -35,14 +36,29 @@ class LLMRegistry: + """Registry for LLMs.""" @staticmethod def new_llm(model:...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/registry.py
Add docstrings to incomplete 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...
--- +++ @@ -33,8 +33,26 @@ class SaveFilesAsArtifactsPlugin(BasePlugin): + """A plugin that saves files embedded in user messages as artifacts. + + This is useful to allow users to upload files in the chat experience and have + those files available to the agent within the current session. + + We use Blob.displ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/plugins/save_files_as_artifacts_plugin.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...
--- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Migration runner to upgrade schemas to the latest version.""" from __future__ import annotations @@ -42,6 +43,29 @@ def upgrade(source_db_url: str, dest_db_url: str): + """Mi...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/sessions/migration/migration_runner.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...
--- +++ @@ -169,6 +169,13 @@ def _ensure_litellm_imported() -> None: + """Imports LiteLLM with safe defaults. + + LiteLLM defaults to DEV mode, which autoloads a local `.env` at import time. + ADK should not implicitly load `.env` just because LiteLLM is installed. + + Users can opt into LiteLLM's default behav...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/models/lite_llm.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,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""A simple iterative prompt optimizer.""" from __future__ import annotations @@ -53,6 +54,7 @@ class SimplePromptOptimizerConfig(BaseModel): + """Configuration for the Iterativ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/optimization/simple_prompt_optimizer.py
Document this module 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...
--- +++ @@ -27,6 +27,11 @@ class BasePlanner(ABC): + """Abstract base class for all planners. + + The planner allows the agent to generate plans for the queries to guide its + action. + """ @abc.abstractmethod def build_planning_instruction( @@ -34,6 +39,15 @@ readonly_context: ReadonlyContext, ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/planners/base_planner.py
Write beginner-friendly 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,7 @@ class SamplingResult(BaseModel): + """Base class for evaluation results of the candidate agent on the batch of examples.""" scores: dict[str, float] = Field( required=True, @@ -42,6 +43,11 @@ class AgentWithScores(BaseModel): + """An optimized agent with its scores. + + ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/optimization/data_types.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...
--- +++ @@ -26,6 +26,7 @@ class AgentOptimizer(ABC, Generic[SamplingResultT, AgentWithScoresT]): + """Base class for agent optimizers.""" @abstractmethod async def optimize( @@ -33,4 +34,16 @@ initial_agent: Agent, sampler: Sampler[SamplingResultT], ) -> OptimizerResult[AgentWithScoresT]: -...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/optimization/agent_optimizer.py
Help me write clear 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,16 +25,24 @@ class Sampler(ABC, Generic[SamplingResultT]): + """Base class for agent optimizers to sample and score candidate agents. + + The developer must implement this interface for their evaluation service to + work with the optimizer. The optimizer will call the sample_and_score method + to...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/optimization/sampler.py
Add documentation for all 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...
--- +++ @@ -90,6 +90,7 @@ use_row_level_locking: bool, missing_message: str, ) -> _StorageStateT: + """Returns a state row, raising if the row is missing.""" stmt = select(state_model).filter(*predicates) if use_row_level_locking: stmt = stmt.with_for_update() @@ -111,6 +112,7 @@ user_state: d...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/sessions/database_session_service.py
Write reusable 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...
--- +++ @@ -33,6 +33,11 @@ class PlanReActPlanner(BasePlanner): + """Plan-Re-Act planner that constrains the LLM response to generate a plan before any action/observation. + + Note: this planner does not require the model to support built-in thinking + features or setting the thinking config. + """ @overri...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/planners/plan_re_act_planner.py
Add docstrings that explain 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...
--- +++ @@ -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. +"""Migration script from SQLAlchemy SQLite to the new SQLite JSON schema.""" from __future__ import annotation...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/sessions/migration/migrate_from_sqlalchemy_sqlite.py
Write Python docstrings for this snippet
# 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. +"""Platform module for abstracting system time generation.""" from __future__ import annotations @@ -26,12 +27,20 @@ def set_time_provider(provider: Callable[[], float]) -> None:...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/platform/time.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...
--- +++ @@ -12,6 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""The v1 database schema for the DatabaseSessionService. + +This module defines SQLAlchemy models for storing session and event data +in a relational database with the "events" table us...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/sessions/schemas/v1.py
Add structured docstrings to improve clarity
# 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. +"""Utility functions for Agent Skills.""" from __future__ import annotations @@ -37,6 +38,14 @@ def _load_dir(directory: pathlib.Path) -> dict[str, str]: + """Recursively load f...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/skills/_utils.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...
--- +++ @@ -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. +"""Database schema version check utility.""" from __future__ import annotations @@ -29,6 +30,7 @@ def _g...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/sessions/migration/_schema_check_utils.py
Add well-formatted 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. +"""Data models for Agent Skills.""" from __future__ import annotations @@ -29,6 +30,22 @@ class Frontmatter(BaseModel): + """L1 skill content: metadata parsed from SKILL.md for ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/skills/models.py
Add docstrings to incomplete 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...
--- +++ @@ -108,6 +108,15 @@ def _safe_json_serialize(obj) -> str: + """Convert any Python object to a JSON-serializable type or string. + + Args: + obj: The object to serialize. + + Returns: + The JSON-serialized object string or <non-serializable> if the object cannot + be serialized. + """ try:...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/telemetry/tracing.py
Fully document this Python code with 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,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Debug logging plugin for capturing complete interaction data to a file.""" from __future__ import annotations @@ -43,6 +44,7 @@ class _DebugEntry(BaseModel): + """A single de...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/plugins/debug_logging_plugin.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. +"""Platform module for abstracting unique ID generation.""" from __future__ import annotations @@ -26,12 +27,19 @@ def set_id_provider(provider: Callable[[], str]) -> None: + ""...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/platform/uuid.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...
--- +++ @@ -95,6 +95,7 @@ def _after_fork_in_child() -> None: + """Reset every living plugin instance after os.fork().""" for plugin in list(_LIVE_PLUGINS): try: plugin._reset_runtime_state() @@ -107,6 +108,11 @@ def _safe_callback(func): + """Decorator that catches and logs exceptions in plugi...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/plugins/bigquery_agent_analytics_plugin.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...
--- +++ @@ -32,18 +32,48 @@ class GlobalInstructionPlugin(BasePlugin): + """Plugin that provides global instructions functionality at the App level. + + This plugin replaces the deprecated global_instruction field on LlmAgent. + Global instructions are applied to all agents in the application, providing + a con...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/plugins/global_instruction_plugin.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,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Module for skill prompt generation.""" from __future__ import annotations @@ -27,6 +28,15 @@ def format_skills_as_xml( skills: List[Union[models.Frontmatter, models.Skill]], ...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/skills/prompt.py
Generate NumPy-style docstrings
# Copyright 2024 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...
--- +++ @@ -52,6 +52,7 @@ def _handle_params_as_deferred_annotations( param: inspect.Parameter, annotation_under_future: dict[str, Any], name: str ) -> inspect.Parameter: + """Catches the case when type hints are stored as strings.""" if isinstance(param.annotation, str): param = param.replace(annotation...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/tools/_function_parameter_parse_util.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 in 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...
--- +++ @@ -39,8 +39,75 @@ class BasePlugin(ABC): + """Base class for creating plugins. + + Plugins provide a structured way to intercept and modify agent, tool, and + LLM behaviors at critical execution points in a callback manner. While agent + callbacks apply to a particular agent, plugins applies globally t...
https://raw.githubusercontent.com/google/adk-python/HEAD/src/google/adk/plugins/base_plugin.py