Skip to content

Commit 3035633

Browse files
Google APIscopybara-github
authored andcommitted
feat: Add ability to specify mocked tool responses in ExecuteTool
feat: Add ExportEvaluation RPC feat: Add support for app level fallback config feat: Add evaluation run and result information to ImportEvaluationsResponse PiperOrigin-RevId: 899708731
1 parent fc96870 commit 3035633

8 files changed

Lines changed: 280 additions & 1 deletion

File tree

google/cloud/ces/v1beta/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ proto_library(
5252
"guardrail.proto",
5353
"mcp_tool.proto",
5454
"mcp_toolset.proto",
55+
"mocks.proto",
5556
"omnichannel.proto",
5657
"omnichannel_service.proto",
5758
"open_api_tool.proto",
@@ -391,6 +392,7 @@ load(
391392

392393
csharp_proto_library(
393394
name = "ces_csharp_proto",
395+
extra_opts = [],
394396
deps = [":ces_proto"],
395397
)
396398

google/cloud/ces/v1beta/app.proto

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,32 @@ message LoggingSettings {
424424

425425
// Settings to describe how errors should be handled in the app.
426426
message ErrorHandlingSettings {
427+
// Configuration for handling fallback responses.
428+
message FallbackResponseConfig {
429+
// Optional. The fallback messages in case of system errors (e.g. LLM
430+
// errors), mapped by [supported language
431+
// code](https://docs.cloud.google.com/customer-engagement-ai/conversational-agents/ps/reference/language).
432+
map<string, string> custom_fallback_messages = 1
433+
[(google.api.field_behavior) = OPTIONAL];
434+
435+
// Optional. The maximum number of fallback attempts to make before the
436+
// agent emitting [EndSession][google.cloud.ces.v1beta.EndSession] Signal.
437+
int32 max_fallback_attempts = 2 [(google.api.field_behavior) = OPTIONAL];
438+
}
439+
440+
// Configuration for ending the session in case of system errors (e.g. LLM
441+
// errors).
442+
message EndSessionConfig {
443+
// Optional. Whether to escalate the session in
444+
// [EndSession][google.cloud.ces.v1beta.EndSession]. If session is
445+
// escalated, [metadata in
446+
// EndSession][google.cloud.ces.v1beta.EndSession.metadata] will contain
447+
// `session_escalated = true`. See
448+
// https://docs.cloud.google.com/customer-engagement-ai/conversational-agents/ps/deploy/google-telephony-platform#transfer_a_call_to_a_human_agent
449+
// for details.
450+
optional bool escalate_session = 1 [(google.api.field_behavior) = OPTIONAL];
451+
}
452+
427453
// Defines the strategy for handling errors.
428454
enum ErrorHandlingStrategy {
429455
// Unspecified error handling strategy.
@@ -444,6 +470,15 @@ message ErrorHandlingSettings {
444470
// Optional. The strategy to use for error handling.
445471
ErrorHandlingStrategy error_handling_strategy = 1
446472
[(google.api.field_behavior) = OPTIONAL];
473+
474+
// Optional. Configuration for handling fallback responses.
475+
FallbackResponseConfig fallback_response_config = 2
476+
[(google.api.field_behavior) = OPTIONAL];
477+
478+
// Optional. Configuration for ending the session in case of system errors
479+
// (e.g. LLM errors).
480+
EndSessionConfig end_session_config = 3
481+
[(google.api.field_behavior) = OPTIONAL];
447482
}
448483

449484
// Threshold settings for metrics in an Evaluation.
@@ -618,6 +653,11 @@ message ConversationLoggingSettings {
618653
// Optional. Whether to disable conversation logging for the sessions.
619654
bool disable_conversation_logging = 1
620655
[(google.api.field_behavior) = OPTIONAL];
656+
657+
// Optional. Controls the retention window for the conversation.
658+
// If not set, the conversation will be retained for 365 days.
659+
google.protobuf.Duration retention_window = 2
660+
[(google.api.field_behavior) = OPTIONAL];
621661
}
622662

623663
// Settings to describe the Cloud Logging behaviors for the app.

google/cloud/ces/v1beta/ces_v1beta.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ types:
1616
- name: google.cloud.ces.v1beta.BatchDeleteConversationsResponse
1717
- name: google.cloud.ces.v1beta.DeleteEvaluationRunOperationMetadata
1818
- name: google.cloud.ces.v1beta.ExportAppResponse
19+
- name: google.cloud.ces.v1beta.ExportEvaluationResultsResponse
20+
- name: google.cloud.ces.v1beta.ExportEvaluationRunsResponse
21+
- name: google.cloud.ces.v1beta.ExportEvaluationsResponse
1922
- name: google.cloud.ces.v1beta.GenerateAppResourceResponse
2023
- name: google.cloud.ces.v1beta.GenerateEvaluationOperationMetadata
2124
- name: google.cloud.ces.v1beta.ImportAppResponse

google/cloud/ces/v1beta/evaluation.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,9 @@ message EvaluationResult {
919919
// Evaluation/Expectation failed. In the case of an evaluation, this means
920920
// that at least one expectation was not met.
921921
FAIL = 2;
922+
923+
// Evaluation/Expectation was skipped.
924+
SKIPPED = 3;
922925
}
923926

924927
// The state of the evaluation result execution.

google/cloud/ces/v1beta/evaluation_service.proto

Lines changed: 135 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import "google/api/annotations.proto";
2020
import "google/api/client.proto";
2121
import "google/api/field_behavior.proto";
2222
import "google/api/resource.proto";
23+
import "google/cloud/ces/v1beta/agent_service.proto";
2324
import "google/cloud/ces/v1beta/conversation.proto";
2425
import "google/cloud/ces/v1beta/evaluation.proto";
2526
import "google/longrunning/operations.proto";
@@ -354,6 +355,20 @@ service EvaluationService {
354355
};
355356
option (google.api.method_signature) = "app";
356357
}
358+
359+
// Exports evaluations.
360+
rpc ExportEvaluations(ExportEvaluationsRequest)
361+
returns (google.longrunning.Operation) {
362+
option (google.api.http) = {
363+
post: "/v1beta/{parent=projects/*/locations/*/apps/*}/evaluations:export"
364+
body: "*"
365+
};
366+
option (google.api.method_signature) = "parent";
367+
option (google.longrunning.operation_info) = {
368+
response_type: "ExportEvaluationsResponse"
369+
metadata_type: "OperationMetadata"
370+
};
371+
}
357372
}
358373

359374
// Response message for
@@ -521,12 +536,27 @@ message ImportEvaluationsResponse {
521536
// The list of evaluations that were imported into the app.
522537
repeated Evaluation evaluations = 1;
523538

539+
// The list of evaluation results that were imported into the app.
540+
repeated EvaluationResult evaluation_results = 4;
541+
542+
// The list of evaluation runs that were imported into the app.
543+
repeated EvaluationRun evaluation_runs = 5;
544+
524545
// Optional. A list of error messages associated with evaluations that failed
525546
// to be imported.
526547
repeated string error_messages = 2 [(google.api.field_behavior) = OPTIONAL];
527548

528-
// The number of evaluations that were not imported due to errors.
549+
// The number of evaluations that either failed to import entirely or
550+
// completed import with one or more errors.
529551
int32 import_failure_count = 3;
552+
553+
// The number of evaluation results that either failed to import entirely or
554+
// completed import with one or more errors.
555+
int32 evaluation_result_import_failure_count = 6;
556+
557+
// The number of evaluation runs that either failed to import entirely or
558+
// completed import with one or more errors.
559+
int32 evaluation_run_import_failure_count = 7;
530560
}
531561

532562
// Represents the metadata of the long-running operation for
@@ -1195,3 +1225,107 @@ message ListEvaluationExpectationsResponse {
11951225
// subsequent pages.
11961226
string next_page_token = 2;
11971227
}
1228+
1229+
// Options for exporting CES evaluation resources.
1230+
message ExportOptions {
1231+
// The format to export the items in. Defaults to JSON if not
1232+
// specified.
1233+
enum ExportFormat {
1234+
// Unspecified format.
1235+
EXPORT_FORMAT_UNSPECIFIED = 0;
1236+
1237+
// JSON format.
1238+
JSON = 1;
1239+
1240+
// YAML format.
1241+
YAML = 2;
1242+
}
1243+
1244+
// Optional. The format to export the evaluation results in. Defaults to JSON
1245+
// if not specified.
1246+
ExportFormat export_format = 1 [(google.api.field_behavior) = OPTIONAL];
1247+
1248+
// Optional. The Google Cloud Storage URI to write the exported Evaluation
1249+
// Results to.
1250+
string gcs_uri = 2 [(google.api.field_behavior) = OPTIONAL];
1251+
}
1252+
1253+
// Request message for
1254+
// [EvaluationService.ExportEvaluations][google.cloud.ces.v1beta.EvaluationService.ExportEvaluations].
1255+
message ExportEvaluationsRequest {
1256+
// Required. The resource name of the app to export evaluations from.
1257+
// Format: `projects/{project}/locations/{location}/apps/{app}`
1258+
string parent = 1 [
1259+
(google.api.field_behavior) = REQUIRED,
1260+
(google.api.resource_reference) = { type: "ces.googleapis.com/App" }
1261+
];
1262+
1263+
// Required. The resource names of the evaluations to export.
1264+
repeated string names = 2 [
1265+
(google.api.field_behavior) = REQUIRED,
1266+
(google.api.resource_reference) = { type: "ces.googleapis.com/Evaluation" }
1267+
];
1268+
1269+
// Optional. The export options for the evaluations.
1270+
ExportOptions export_options = 3 [(google.api.field_behavior) = OPTIONAL];
1271+
1272+
// Optional. Includes evaluation results in the export. At least one of
1273+
// include_evaluation_results or include_evaluations must be set.
1274+
bool include_evaluation_results = 4 [(google.api.field_behavior) = OPTIONAL];
1275+
1276+
// Optional. Includes evaluations in the export. At least one of
1277+
// include_evaluation_results or include_evaluations must be set.
1278+
bool include_evaluations = 5 [(google.api.field_behavior) = OPTIONAL];
1279+
}
1280+
1281+
// Response message for
1282+
// [EvaluationService.ExportEvaluations][google.cloud.ces.v1beta.EvaluationService.ExportEvaluations].
1283+
message ExportEvaluationsResponse {
1284+
// The exported evaluations.
1285+
oneof evaluations {
1286+
// The content of the exported Evaluations. This will be populated if
1287+
// gcs_uri was not specified in the request.
1288+
bytes evaluations_content = 1;
1289+
1290+
// The Google Cloud Storage URI folder where the exported evaluations were
1291+
// written. This will be populated if gcs_uri was specified in the request.
1292+
string evaluations_uri = 2;
1293+
}
1294+
1295+
// Output only. A map of evaluation resource names that could not be exported,
1296+
// to the reason why they failed.
1297+
map<string, string> failed_evaluations = 3
1298+
[(google.api.field_behavior) = OUTPUT_ONLY];
1299+
}
1300+
1301+
// Response message for
1302+
// [EvaluationService.ExportEvaluationResults][google.cloud.ces.v1beta.EvaluationService.ExportEvaluationResults].
1303+
message ExportEvaluationResultsResponse {
1304+
// The exported evaluation results.
1305+
oneof evaluation_results {
1306+
// The content of the exported Evaluation Results. This will be populated if
1307+
// gcs_uri was not specified in the request.
1308+
bytes evaluation_results_content = 1;
1309+
1310+
// The Google Cloud Storage URI folder where the exported Evaluation Results
1311+
// were written. This will be populated if gcs_uri was specified in the
1312+
// request.
1313+
string evaluation_results_uri = 2;
1314+
}
1315+
}
1316+
1317+
// Response message for
1318+
// [EvaluationService.ExportEvaluationRuns][google.cloud.ces.v1beta.EvaluationService.ExportEvaluationRuns].
1319+
message ExportEvaluationRunsResponse {
1320+
// The exported evaluation runs.
1321+
oneof evaluation_runs {
1322+
// The content of the exported Evaluation Runs. This will be populated if
1323+
// gcs_uri was not specified in the request.
1324+
bytes evaluation_runs_content = 1;
1325+
1326+
// The Google Cloud Storage URI folder where the exported Evaluation Runs
1327+
// were written. This will be populated if gcs_uri was specified in the
1328+
// request.
1329+
string evaluation_runs_uri = 2;
1330+
}
1331+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright 2026 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.
14+
15+
syntax = "proto3";
16+
17+
package google.cloud.ces.v1beta;
18+
19+
import "google/api/field_behavior.proto";
20+
import "google/api/resource.proto";
21+
import "google/cloud/ces/v1beta/toolset_tool.proto";
22+
import "google/protobuf/struct.proto";
23+
24+
option go_package = "cloud.google.com/go/ces/apiv1beta/cespb;cespb";
25+
option java_multiple_files = true;
26+
option java_outer_classname = "MocksProto";
27+
option java_package = "com.google.cloud.ces.v1beta";
28+
29+
// A mocked tool call.
30+
//
31+
// Expresses the target tool + a pattern to match against that tool's
32+
// args / inputs. If the pattern matches, then the mock response will be
33+
// returned.
34+
message MockedToolCall {
35+
// The identifier of the tool to mock.
36+
oneof tool_identifier {
37+
// Optional. The name of the tool to mock.
38+
// Format: `projects/{project}/locations/{location}/apps/{app}/tools/{tool}`
39+
string tool_id = 4 [
40+
(google.api.field_behavior) = OPTIONAL,
41+
(google.api.resource_reference) = { type: "ces.googleapis.com/Tool" }
42+
];
43+
44+
// Optional. The toolset to mock.
45+
ToolsetTool toolset = 5 [(google.api.field_behavior) = OPTIONAL];
46+
}
47+
48+
// Optional. Deprecated. Use tool_identifier instead.
49+
string tool = 1 [
50+
deprecated = true,
51+
(google.api.field_behavior) = OPTIONAL,
52+
(google.api.resource_reference) = { type: "ces.googleapis.com/Tool" }
53+
];
54+
55+
// Required. A pattern to match against the args / inputs of all dispatched
56+
// tool calls. If the tool call inputs match this pattern, then mock output
57+
// will be returned.
58+
google.protobuf.Struct expected_args_pattern = 2
59+
[(google.api.field_behavior) = REQUIRED];
60+
61+
// Optional. The mock response / output to return if the tool call args /
62+
// inputs match the pattern.
63+
google.protobuf.Struct mock_response = 3
64+
[(google.api.field_behavior) = OPTIONAL];
65+
}

google/cloud/ces/v1beta/session_service.proto

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import "google/api/field_behavior.proto";
2222
import "google/api/resource.proto";
2323
import "google/cloud/ces/v1beta/common.proto";
2424
import "google/cloud/ces/v1beta/example.proto";
25+
import "google/cloud/ces/v1beta/mocks.proto";
2526
import "google/cloud/ces/v1beta/search_suggestions.proto";
2627
import "google/protobuf/struct.proto";
2728

@@ -148,6 +149,31 @@ enum AudioEncoding {
148149
ALAW = 3;
149150
}
150151

152+
// Mock tool calls configuration for the session.
153+
message MockConfig {
154+
// What to do when a tool call doesn't match any mocked tool calls.
155+
enum UnmatchedToolCallBehavior {
156+
// Default value. This value is unused.
157+
UNMATCHED_TOOL_CALL_BEHAVIOR_UNSPECIFIED = 0;
158+
159+
// Throw an error for any tool calls that don't match a mock expected input
160+
// pattern.
161+
FAIL = 1;
162+
163+
// For unmatched tool calls, pass the tool call through to real tool.
164+
PASS_THROUGH = 2;
165+
}
166+
167+
// Optional. All tool calls to mock for the duration of the session.
168+
repeated MockedToolCall mocked_tool_calls = 1
169+
[(google.api.field_behavior) = OPTIONAL];
170+
171+
// Required. Beavhior for tool calls that don't match any args patterns in
172+
// mocked_tool_calls.
173+
UnmatchedToolCallBehavior unmatched_tool_call_behavior = 2
174+
[(google.api.field_behavior) = REQUIRED];
175+
}
176+
151177
// InputAudioConfig configures how the CES agent should interpret the incoming
152178
// audio data.
153179
message InputAudioConfig {

google/cloud/ces/v1beta/tool_service.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import "google/api/client.proto";
2121
import "google/api/field_behavior.proto";
2222
import "google/api/resource.proto";
2323
import "google/cloud/ces/v1beta/schema.proto";
24+
import "google/cloud/ces/v1beta/session_service.proto";
2425
import "google/cloud/ces/v1beta/tool.proto";
2526
import "google/cloud/ces/v1beta/toolset_tool.proto";
2627
import "google/protobuf/struct.proto";
@@ -105,6 +106,11 @@ message ExecuteToolRequest {
105106
// Optional. The input parameters and values for the tool in JSON object
106107
// format.
107108
google.protobuf.Struct args = 2 [(google.api.field_behavior) = OPTIONAL];
109+
110+
// Optional. Mock configuration for the tool execution.
111+
// If this field is set, tools that call other tools will be
112+
// mocked based on the provided patterns and responses.
113+
MockConfig mock_config = 7 [(google.api.field_behavior) = OPTIONAL];
108114
}
109115

110116
// Response message for

0 commit comments

Comments
 (0)