Skip to content

Commit c0554e4

Browse files
Jacksunweicopybara-github
authored andcommitted
feat(conformance): add an ADK plugin to record Llm request/response and tool call/result to recordings.yaml file
Also moves the `Recordings` pydantic models into this plugins/ package. Key features: - Records LLM requests/responses and tool calls/results to YAML files in `generated-recordings.yaml`. - Use session state to determine where to read and output recordings. PiperOrigin-RevId: 807969100
1 parent 6bd33e1 commit c0554e4

4 files changed

Lines changed: 501 additions & 68 deletions

File tree

src/google/adk/cli/conformance/test_case.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,8 @@
1414

1515
from __future__ import annotations
1616

17-
from typing import Optional
18-
19-
from google.genai import types
2017
from pydantic import BaseModel
2118
from pydantic import ConfigDict
22-
from pydantic import Field
23-
24-
from ...models.llm_request import LlmRequest
25-
from ...models.llm_response import LlmResponse
2619

2720

2821
class TestSpec(BaseModel):
@@ -44,64 +37,3 @@ class TestSpec(BaseModel):
4437

4538
user_messages: list[str]
4639
"""Sequence of user messages to send to the agent during test execution."""
47-
48-
49-
class LlmRecording(BaseModel):
50-
"""Paired LLM request and response."""
51-
52-
model_config = ConfigDict(
53-
extra="forbid",
54-
)
55-
56-
llm_request: LlmRequest
57-
"""The LLM request."""
58-
59-
llm_response: LlmResponse
60-
"""The LLM response."""
61-
62-
63-
class ToolRecording(BaseModel):
64-
"""Paired tool call and response."""
65-
66-
model_config = ConfigDict(
67-
extra="forbid",
68-
)
69-
70-
tool_call: types.FunctionCall
71-
"""The tool call."""
72-
73-
tool_response: types.FunctionResponse
74-
"""The tool response."""
75-
76-
77-
class Recording(BaseModel):
78-
"""Single interaction recording, ordered by request timestamp."""
79-
80-
model_config = ConfigDict(
81-
extra="forbid",
82-
)
83-
84-
user_message_index: int
85-
"""Index of the user message this recording belongs to (0-based)."""
86-
87-
agent_name: str
88-
"""Name of the agent."""
89-
90-
# oneof fields - start
91-
llm_recording: Optional[LlmRecording] = None
92-
"""LLM request-response pair."""
93-
94-
tool_recording: Optional[ToolRecording] = None
95-
"""Tool call-response pair."""
96-
# oneof fields - end
97-
98-
99-
class Recordings(BaseModel):
100-
"""All recordings in chronological order."""
101-
102-
model_config = ConfigDict(
103-
extra="forbid",
104-
)
105-
106-
recordings: list[Recording] = Field(default_factory=list)
107-
"""Chronological list of all recordings."""
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.

0 commit comments

Comments
 (0)