Skip to content

Commit dfee06a

Browse files
wuliang229copybara-github
authored andcommitted
feat(config): support input/output schema by fully-qualified code reference
PiperOrigin-RevId: 785541326
1 parent 2aab1cf commit dfee06a

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

src/google/adk/agents/config_schemas/AgentConfig.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,28 @@
163163
"default": null,
164164
"title": "Disallow Transfer To Peers"
165165
},
166+
"input_schema": {
167+
"anyOf": [
168+
{
169+
"$ref": "#/$defs/CodeConfig"
170+
},
171+
{
172+
"type": "null"
173+
}
174+
],
175+
"default": null
176+
},
177+
"output_schema": {
178+
"anyOf": [
179+
{
180+
"$ref": "#/$defs/CodeConfig"
181+
},
182+
{
183+
"type": "null"
184+
}
185+
],
186+
"default": null
187+
},
166188
"output_key": {
167189
"anyOf": [
168190
{

src/google/adk/agents/llm_agent.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ def from_config(
563563
config_abs_path: str,
564564
) -> LlmAgent:
565565
from .config_agent_utils import resolve_callbacks
566+
from .config_agent_utils import resolve_code_reference
566567

567568
agent = super().from_config(config, config_abs_path)
568569
if config.model:
@@ -575,6 +576,10 @@ def from_config(
575576
agent.disallow_transfer_to_peers = config.disallow_transfer_to_peers
576577
if config.include_contents != 'default':
577578
agent.include_contents = config.include_contents
579+
if config.input_schema:
580+
agent.input_schema = resolve_code_reference(config.input_schema)
581+
if config.output_schema:
582+
agent.output_schema = resolve_code_reference(config.output_schema)
578583
if config.output_key:
579584
agent.output_key = config.output_key
580585
if config.tools:
@@ -619,6 +624,12 @@ class LlmAgentConfig(BaseAgentConfig):
619624
disallow_transfer_to_peers: Optional[bool] = None
620625
"""Optional. LlmAgent.disallow_transfer_to_peers."""
621626

627+
input_schema: Optional[CodeConfig] = None
628+
"""Optional. LlmAgent.input_schema."""
629+
630+
output_schema: Optional[CodeConfig] = None
631+
"""Optional. LlmAgent.output_schema."""
632+
622633
output_key: Optional[str] = None
623634
"""Optional. LlmAgent.output_key."""
624635

0 commit comments

Comments
 (0)