Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 135 additions & 2 deletions google/genai/_interactions/types/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
127 changes: 126 additions & 1 deletion google/genai/_interactions/types/interaction_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
"ResponseFormatResponseFormatList",
"BaseCreateAgentInteractionParams",
"AgentConfig",
"AgentConfigCodeMender",
"AgentConfigCodeMenderFindRequest",
"AgentConfigCodeMenderFindRequestSourceFile",
"AgentConfigCodeMenderFixRequest",
"AgentConfigCodeMenderFixRequestSourceFile",
"AgentConfigCodeMenderSessionConfig",
"CreateModelInteractionParamsNonStreaming",
"CreateModelInteractionParamsStreaming",
"CreateAgentInteractionParamsNonStreaming",
Expand Down Expand Up @@ -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):
Expand Down
Loading