From 5035a72365b237b4ef5c8608ff9ea4706dcb4ae0 Mon Sep 17 00:00:00 2001 From: Google Team Member Date: Fri, 29 May 2026 16:27:21 -0700 Subject: [PATCH] feat(interaction-api): Add CodeMenderAgentConfig to AgentInteraction PiperOrigin-RevId: 923656331 --- .../genai/_interactions/types/interaction.py | 137 +++++++++++++++++- .../types/interaction_create_params.py | 127 +++++++++++++++- 2 files changed, 261 insertions(+), 3 deletions(-) diff --git a/google/genai/_interactions/types/interaction.py b/google/genai/_interactions/types/interaction.py index 505d1f63a..14e19a889 100644 --- a/google/genai/_interactions/types/interaction.py +++ b/google/genai/_interactions/types/interaction.py @@ -43,10 +43,143 @@ from .image_response_format import ImageResponseFormat from .deep_research_agent_config import DeepResearchAgentConfig -__all__ = ["Interaction", "AgentConfig", "Environment", "Input", "ResponseFormat", "ResponseFormatResponseFormatList"] +__all__ = [ + "Interaction", + "AgentConfig", + "AgentConfigCodeMender", + "AgentConfigCodeMenderFindRequest", + "AgentConfigCodeMenderFindRequestSourceFile", + "AgentConfigCodeMenderFixRequest", + "AgentConfigCodeMenderFixRequestSourceFile", + "AgentConfigCodeMenderSessionConfig", + "Environment", + "Input", + "ResponseFormat", + "ResponseFormatResponseFormatList", +] + + +class AgentConfigCodeMenderFindRequestSourceFile(BaseModel): + """Content of a single file in the codebase.""" + + content: Optional[str] = None + """The UTF-8 encoded text content of the file.""" + + path: Optional[str] = None + """The relative path of the file from the project root.""" + + +class AgentConfigCodeMenderFindRequest(BaseModel): + """Parameters for finding vulnerabilities. + + This field is only applicable when + session_type is SESSION_TYPE_FIND. + """ + + description: Optional[str] = None + """ + Additional context or custom instructions provided by the user to guide the + vulnerability analysis. + """ + + finding_id: Optional[str] = None + """The identifier of a specific finding to verify. + + This is primarily used in VERIFY mode to focus the agent's execution-based + validation on a single vulnerability. + """ + + source_files: Optional[List[AgentConfigCodeMenderFindRequestSourceFile]] = None + """A list of source files to provide as context for the scan.""" + + +class AgentConfigCodeMenderFixRequestSourceFile(BaseModel): + """Content of a single file in the codebase.""" + + content: Optional[str] = None + """The UTF-8 encoded text content of the file.""" + + path: Optional[str] = None + """The relative path of the file from the project root.""" + + +class AgentConfigCodeMenderFixRequest(BaseModel): + """Parameters for fixing vulnerabilities. + + This field is only applicable when + session_type is SESSION_TYPE_FIX. + """ + + description: Optional[str] = None + """ + Additional context or custom instructions provided by the user to guide the + patch generation process. + """ + + finding_id: Optional[str] = None + """The identifier of the specific security finding to be remediated. + + This ID maps to a previously discovered vulnerability. + """ + + source_files: Optional[List[AgentConfigCodeMenderFixRequestSourceFile]] = None + """A list of source files providing context for the remediation. + + These files are typically the ones containing the identified vulnerability. + """ + + +class AgentConfigCodeMenderSessionConfig(BaseModel): + """ + Optional session-specific configurations to override default agent + behavior. + """ + + max_rounds: Optional[int] = None + """ + The maximum number of interaction rounds the agent is allowed to perform before + reaching a timeout. + """ + + pipeline_mode: Optional[Literal["scan", "find", "full", "verify"]] = None + """The pipeline mode of a CodeMender session. + + It can only be used for a find session. + """ + + topology: Optional[str] = None + """The cognitive architecture or "thinking" topology used by the agent (e.g. + + "default", "deep"). + """ + + +class AgentConfigCodeMender(BaseModel): + """Configuration for the CodeMender agent.""" + + type: Literal["code-mender"] + + find_request: Optional[AgentConfigCodeMenderFindRequest] = None + """Parameters for finding vulnerabilities. + + This field is only applicable when session_type is SESSION_TYPE_FIND. + """ + + fix_request: Optional[AgentConfigCodeMenderFixRequest] = None + """Parameters for fixing vulnerabilities. + + This field is only applicable when session_type is SESSION_TYPE_FIX. + """ + + session_config: Optional[AgentConfigCodeMenderSessionConfig] = None + """Optional session-specific configurations to override default agent behavior.""" + + session_type: Optional[Literal["find", "fix"]] = None + """The session type of a CodeMender session.""" + AgentConfig: TypeAlias = Annotated[ - Union[DynamicAgentConfig, DeepResearchAgentConfig], PropertyInfo(discriminator="type") + Union[DynamicAgentConfig, DeepResearchAgentConfig, AgentConfigCodeMender], PropertyInfo(discriminator="type") ] Environment: TypeAlias = Union[str, environment.Environment] diff --git a/google/genai/_interactions/types/interaction_create_params.py b/google/genai/_interactions/types/interaction_create_params.py index 61a7761a5..cde6e9902 100644 --- a/google/genai/_interactions/types/interaction_create_params.py +++ b/google/genai/_interactions/types/interaction_create_params.py @@ -46,6 +46,12 @@ "ResponseFormatResponseFormatList", "BaseCreateAgentInteractionParams", "AgentConfig", + "AgentConfigCodeMender", + "AgentConfigCodeMenderFindRequest", + "AgentConfigCodeMenderFindRequestSourceFile", + "AgentConfigCodeMenderFixRequest", + "AgentConfigCodeMenderFixRequestSourceFile", + "AgentConfigCodeMenderSessionConfig", "CreateModelInteractionParamsNonStreaming", "CreateModelInteractionParamsStreaming", "CreateAgentInteractionParamsNonStreaming", @@ -202,7 +208,126 @@ class BaseCreateAgentInteractionParams(TypedDict, total=False): """ -AgentConfig: TypeAlias = Union[DynamicAgentConfigParam, DeepResearchAgentConfigParam] +class AgentConfigCodeMenderFindRequestSourceFile(TypedDict, total=False): + """Content of a single file in the codebase.""" + + content: str + """The UTF-8 encoded text content of the file.""" + + path: str + """The relative path of the file from the project root.""" + + +class AgentConfigCodeMenderFindRequest(TypedDict, total=False): + """Parameters for finding vulnerabilities. + + This field is only applicable when + session_type is SESSION_TYPE_FIND. + """ + + description: str + """ + Additional context or custom instructions provided by the user to guide the + vulnerability analysis. + """ + + finding_id: str + """The identifier of a specific finding to verify. + + This is primarily used in VERIFY mode to focus the agent's execution-based + validation on a single vulnerability. + """ + + source_files: Iterable[AgentConfigCodeMenderFindRequestSourceFile] + """A list of source files to provide as context for the scan.""" + + +class AgentConfigCodeMenderFixRequestSourceFile(TypedDict, total=False): + """Content of a single file in the codebase.""" + + content: str + """The UTF-8 encoded text content of the file.""" + + path: str + """The relative path of the file from the project root.""" + + +class AgentConfigCodeMenderFixRequest(TypedDict, total=False): + """Parameters for fixing vulnerabilities. + + This field is only applicable when + session_type is SESSION_TYPE_FIX. + """ + + description: str + """ + Additional context or custom instructions provided by the user to guide the + patch generation process. + """ + + finding_id: str + """The identifier of the specific security finding to be remediated. + + This ID maps to a previously discovered vulnerability. + """ + + source_files: Iterable[AgentConfigCodeMenderFixRequestSourceFile] + """A list of source files providing context for the remediation. + + These files are typically the ones containing the identified vulnerability. + """ + + +class AgentConfigCodeMenderSessionConfig(TypedDict, total=False): + """ + Optional session-specific configurations to override default agent + behavior. + """ + + max_rounds: int + """ + The maximum number of interaction rounds the agent is allowed to perform before + reaching a timeout. + """ + + pipeline_mode: Literal["scan", "find", "full", "verify"] + """The pipeline mode of a CodeMender session. + + It can only be used for a find session. + """ + + topology: str + """The cognitive architecture or "thinking" topology used by the agent (e.g. + + "default", "deep"). + """ + + +class AgentConfigCodeMender(TypedDict, total=False): + """Configuration for the CodeMender agent.""" + + type: Required[Literal["code-mender"]] + + find_request: AgentConfigCodeMenderFindRequest + """Parameters for finding vulnerabilities. + + This field is only applicable when session_type is SESSION_TYPE_FIND. + """ + + fix_request: AgentConfigCodeMenderFixRequest + """Parameters for fixing vulnerabilities. + + This field is only applicable when session_type is SESSION_TYPE_FIX. + """ + + session_config: AgentConfigCodeMenderSessionConfig + """Optional session-specific configurations to override default agent behavior.""" + + session_type: Literal["find", "fix"] + """The session type of a CodeMender session.""" + + +AgentConfig: TypeAlias = Union[DynamicAgentConfigParam, DeepResearchAgentConfigParam, AgentConfigCodeMender] class CreateModelInteractionParamsNonStreaming(BaseCreateModelInteractionParams, total=False):