Skip to content

Commit 23a2bf5

Browse files
google-genai-botcopybara-github
authored andcommitted
feat(interaction-api): Add CodeMenderAgentConfig to the Interactions API AgentInteraction proto
PiperOrigin-RevId: 923642395
1 parent 3d5c1d0 commit 23a2bf5

2 files changed

Lines changed: 307 additions & 6 deletions

File tree

google/genai/_interactions/types/interaction.py

Lines changed: 158 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717

1818
from typing import TYPE_CHECKING, Any, Set, Dict, List, Tuple, Union, Optional, cast
1919
from datetime import datetime
20-
from typing_extensions import Literal, Annotated, TypeAlias, override
20+
from typing_extensions import Literal, TypeAlias, override
2121

2222
from . import environment
2323
from .step import Step
2424
from .tool import Tool
2525
from .model import Model
2626
from .usage import Usage
27-
from .._utils import PropertyInfo
2827
from .content import Content
2928
from .._compat import PYDANTIC_V1
3029
from .._models import BaseModel
@@ -43,10 +42,164 @@
4342
from .image_response_format import ImageResponseFormat
4443
from .deep_research_agent_config import DeepResearchAgentConfig
4544

46-
__all__ = ["Interaction", "AgentConfig", "Environment", "Input", "ResponseFormat", "ResponseFormatResponseFormatList"]
45+
__all__ = [
46+
"Interaction",
47+
"AgentConfig",
48+
"AgentConfigFindRequest",
49+
"AgentConfigFindRequestSessionConfig",
50+
"AgentConfigFindRequestSourceFile",
51+
"AgentConfigFixRequest",
52+
"AgentConfigFixRequestSessionConfig",
53+
"AgentConfigFixRequestSourceFile",
54+
"Environment",
55+
"Input",
56+
"ResponseFormat",
57+
"ResponseFormatResponseFormatList",
58+
]
59+
60+
61+
class AgentConfigFindRequestSessionConfig(BaseModel):
62+
"""
63+
Optional session-specific configurations to override default agent
64+
behavior.
65+
"""
66+
67+
max_rounds: Optional[int] = None
68+
"""
69+
The maximum number of interaction rounds the agent is allowed to perform before
70+
reaching a timeout.
71+
"""
72+
73+
pipeline_mode: Optional[Literal["scan", "verify"]] = None
74+
"""The pipeline mode of a CodeMender session.
75+
76+
It can only be used for a find session.
77+
"""
78+
79+
topology: Optional[str] = None
80+
"""The cognitive architecture or "thinking" topology used by the agent (e.g.
81+
82+
"default", "deep").
83+
"""
84+
85+
86+
class AgentConfigFindRequestSourceFile(BaseModel):
87+
"""Content of a single file in the codebase."""
88+
89+
content: Optional[str] = None
90+
"""The UTF-8 encoded text content of the file."""
91+
92+
path: Optional[str] = None
93+
"""The relative path of the file from the project root."""
94+
95+
96+
class AgentConfigFindRequest(BaseModel):
97+
"""
98+
Request parameters specific to FIND sessions, used for discovering
99+
vulnerabilities in a codebase.
100+
"""
101+
102+
request: Literal["find_request"]
103+
104+
description: Optional[str] = None
105+
"""
106+
Additional context or custom instructions provided by the user to guide the
107+
vulnerability analysis.
108+
"""
109+
110+
finding_id: Optional[str] = None
111+
"""The identifier of a specific finding to verify.
112+
113+
This is primarily used in VERIFY mode to focus the agent's execution-based
114+
validation on a single vulnerability.
115+
"""
116+
117+
session_config: Optional[AgentConfigFindRequestSessionConfig] = None
118+
"""Optional session-specific configurations to override default agent behavior."""
119+
120+
session_id: Optional[str] = None
121+
"""
122+
Parameter for grouping multiple interactions that belong to the same CodeMender
123+
session.
124+
"""
125+
126+
source_files: Optional[List[AgentConfigFindRequestSourceFile]] = None
127+
"""A list of source files to provide as context for the scan."""
128+
129+
130+
class AgentConfigFixRequestSessionConfig(BaseModel):
131+
"""
132+
Optional session-specific configurations to override default agent
133+
behavior.
134+
"""
135+
136+
max_rounds: Optional[int] = None
137+
"""
138+
The maximum number of interaction rounds the agent is allowed to perform before
139+
reaching a timeout.
140+
"""
141+
142+
pipeline_mode: Optional[Literal["scan", "verify"]] = None
143+
"""The pipeline mode of a CodeMender session.
144+
145+
It can only be used for a find session.
146+
"""
147+
148+
topology: Optional[str] = None
149+
"""The cognitive architecture or "thinking" topology used by the agent (e.g.
150+
151+
"default", "deep").
152+
"""
153+
154+
155+
class AgentConfigFixRequestSourceFile(BaseModel):
156+
"""Content of a single file in the codebase."""
157+
158+
content: Optional[str] = None
159+
"""The UTF-8 encoded text content of the file."""
160+
161+
path: Optional[str] = None
162+
"""The relative path of the file from the project root."""
163+
164+
165+
class AgentConfigFixRequest(BaseModel):
166+
"""
167+
Request parameters specific to FIX sessions, used for generating and
168+
validating security patches.
169+
"""
170+
171+
request: Literal["fix_request"]
172+
173+
description: Optional[str] = None
174+
"""
175+
Additional context or custom instructions provided by the user to guide the
176+
patch generation process.
177+
"""
178+
179+
finding_id: Optional[str] = None
180+
"""The identifier of the specific security finding to be remediated.
181+
182+
This ID maps to a previously discovered vulnerability.
183+
"""
184+
185+
session_config: Optional[AgentConfigFixRequestSessionConfig] = None
186+
"""Optional session-specific configurations to override default agent behavior."""
187+
188+
session_id: Optional[str] = None
189+
"""
190+
Parameter for grouping multiple interactions that belong to the same CodeMender
191+
session.
192+
"""
193+
194+
source_files: Optional[List[AgentConfigFixRequestSourceFile]] = None
195+
"""A list of source files providing context for the remediation.
196+
197+
These files are typically the ones containing the identified vulnerability.
198+
"""
199+
47200

48-
AgentConfig: TypeAlias = Annotated[
49-
Union[DynamicAgentConfig, DeepResearchAgentConfig], PropertyInfo(discriminator="type")
201+
AgentConfig: TypeAlias = Union[
202+
DeepResearchAgentConfig, DynamicAgentConfig, AgentConfigFindRequest, AgentConfigFixRequest
50203
]
51204

52205
Environment: TypeAlias = Union[str, environment.Environment]

google/genai/_interactions/types/interaction_create_params.py

Lines changed: 149 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
"ResponseFormatResponseFormatList",
4747
"BaseCreateAgentInteractionParams",
4848
"AgentConfig",
49+
"AgentConfigFindRequest",
50+
"AgentConfigFindRequestSessionConfig",
51+
"AgentConfigFindRequestSourceFile",
52+
"AgentConfigFixRequest",
53+
"AgentConfigFixRequestSessionConfig",
54+
"AgentConfigFixRequestSourceFile",
4955
"CreateModelInteractionParamsNonStreaming",
5056
"CreateModelInteractionParamsStreaming",
5157
"CreateAgentInteractionParamsNonStreaming",
@@ -203,7 +209,149 @@ class BaseCreateAgentInteractionParams(TypedDict, total=False):
203209
"""
204210

205211

206-
AgentConfig: TypeAlias = Union[DynamicAgentConfigParam, DeepResearchAgentConfigParam]
212+
class AgentConfigFindRequestSessionConfig(TypedDict, total=False):
213+
"""
214+
Optional session-specific configurations to override default agent
215+
behavior.
216+
"""
217+
218+
max_rounds: int
219+
"""
220+
The maximum number of interaction rounds the agent is allowed to perform before
221+
reaching a timeout.
222+
"""
223+
224+
pipeline_mode: Literal["scan", "verify"]
225+
"""The pipeline mode of a CodeMender session.
226+
227+
It can only be used for a find session.
228+
"""
229+
230+
topology: str
231+
"""The cognitive architecture or "thinking" topology used by the agent (e.g.
232+
233+
"default", "deep").
234+
"""
235+
236+
237+
class AgentConfigFindRequestSourceFile(TypedDict, total=False):
238+
"""Content of a single file in the codebase."""
239+
240+
content: str
241+
"""The UTF-8 encoded text content of the file."""
242+
243+
path: str
244+
"""The relative path of the file from the project root."""
245+
246+
247+
class AgentConfigFindRequest(TypedDict, total=False):
248+
"""
249+
Request parameters specific to FIND sessions, used for discovering
250+
vulnerabilities in a codebase.
251+
"""
252+
253+
request: Required[Literal["find_request"]]
254+
255+
description: str
256+
"""
257+
Additional context or custom instructions provided by the user to guide the
258+
vulnerability analysis.
259+
"""
260+
261+
finding_id: str
262+
"""The identifier of a specific finding to verify.
263+
264+
This is primarily used in VERIFY mode to focus the agent's execution-based
265+
validation on a single vulnerability.
266+
"""
267+
268+
session_config: AgentConfigFindRequestSessionConfig
269+
"""Optional session-specific configurations to override default agent behavior."""
270+
271+
session_id: str
272+
"""
273+
Parameter for grouping multiple interactions that belong to the same CodeMender
274+
session.
275+
"""
276+
277+
source_files: Iterable[AgentConfigFindRequestSourceFile]
278+
"""A list of source files to provide as context for the scan."""
279+
280+
281+
class AgentConfigFixRequestSessionConfig(TypedDict, total=False):
282+
"""
283+
Optional session-specific configurations to override default agent
284+
behavior.
285+
"""
286+
287+
max_rounds: int
288+
"""
289+
The maximum number of interaction rounds the agent is allowed to perform before
290+
reaching a timeout.
291+
"""
292+
293+
pipeline_mode: Literal["scan", "verify"]
294+
"""The pipeline mode of a CodeMender session.
295+
296+
It can only be used for a find session.
297+
"""
298+
299+
topology: str
300+
"""The cognitive architecture or "thinking" topology used by the agent (e.g.
301+
302+
"default", "deep").
303+
"""
304+
305+
306+
class AgentConfigFixRequestSourceFile(TypedDict, total=False):
307+
"""Content of a single file in the codebase."""
308+
309+
content: str
310+
"""The UTF-8 encoded text content of the file."""
311+
312+
path: str
313+
"""The relative path of the file from the project root."""
314+
315+
316+
class AgentConfigFixRequest(TypedDict, total=False):
317+
"""
318+
Request parameters specific to FIX sessions, used for generating and
319+
validating security patches.
320+
"""
321+
322+
request: Required[Literal["fix_request"]]
323+
324+
description: str
325+
"""
326+
Additional context or custom instructions provided by the user to guide the
327+
patch generation process.
328+
"""
329+
330+
finding_id: str
331+
"""The identifier of the specific security finding to be remediated.
332+
333+
This ID maps to a previously discovered vulnerability.
334+
"""
335+
336+
session_config: AgentConfigFixRequestSessionConfig
337+
"""Optional session-specific configurations to override default agent behavior."""
338+
339+
session_id: str
340+
"""
341+
Parameter for grouping multiple interactions that belong to the same CodeMender
342+
session.
343+
"""
344+
345+
source_files: Iterable[AgentConfigFixRequestSourceFile]
346+
"""A list of source files providing context for the remediation.
347+
348+
These files are typically the ones containing the identified vulnerability.
349+
"""
350+
351+
352+
AgentConfig: TypeAlias = Union[
353+
DeepResearchAgentConfigParam, DynamicAgentConfigParam, AgentConfigFindRequest, AgentConfigFixRequest
354+
]
207355

208356

209357
class CreateModelInteractionParamsNonStreaming(BaseCreateModelInteractionParams, total=False):

0 commit comments

Comments
 (0)