Skip to content

Commit ae2b5f2

Browse files
committed
Update schema to move away from request model, generalize tool definitions
1 parent 4b5e504 commit ae2b5f2

12 files changed

+346
-259
lines changed

tools/src/main/java/dev/cel/tools/ai/agent_context.proto

Lines changed: 161 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,6 @@ option java_package = "dev.cel.expr.ai";
99
option java_multiple_files = true;
1010
option java_outer_classname = "AgentContextProto";
1111

12-
// AgentRequestContext defines the universal attribute vocabulary for
13-
// an AI-related policy check.
14-
//
15-
// It represents the state of an agent interaction at a specific point in time,
16-
// covering both initial conversation ingress (prompt) and subsequent tool
17-
// execution requests.
18-
message AgentRequestContext {
19-
// A unique identifier for the specific policy request.
20-
string request_id = 1;
21-
22-
// Timestamp of when the request was initiated.
23-
google.protobuf.Timestamp time = 2;
24-
25-
// The context of the agent receiving the request (ingress). Includes the
26-
// user's prompt, agent identity and configuration. This field must be
27-
// populated in all request phases.
28-
Agent agent = 3;
29-
30-
// The identifier of the agent/entity that invoked this request.
31-
string last_agent = 4; // e.g. "agents/travel-concierge"
32-
33-
// The identifier of the agent being invoked next (if applicable).
34-
string next_agent = 5; // e.g. "agents/booking-tool"
35-
}
36-
3712
// Agent represents the AI System or Service being governed.
3813
// It encapsulates the static configuration (Manifests, Identity) and the
3914
// dynamic runtime state (Context, Inputs, Outputs).
@@ -54,10 +29,12 @@ message Agent {
5429
// The provider or vendor responsible for hosting/managing this agent.
5530
AgentProvider provider = 5;
5631

57-
// TODO: Trimmed down version of auth
58-
// google.rpc.context.AttributeContext.Auth auth = 6;
32+
// Identity of the Agent itself (Service Account / Principal)
33+
// Independent of 'request.auth.principal' which may be the end user
34+
// credentials or the agent's identity
35+
AgentAuth auth = 6;
5936

60-
// The accumulated security context (Trust, Sensitivity, History).
37+
// The accumulated security context (Trust, Sensitivity, Data Sources).
6138
AgentContext context = 7;
6239

6340
// The current turn's input (Prompt + Attachments)
@@ -67,6 +44,31 @@ message Agent {
6744
AgentMessage output = 9;
6845
}
6946

47+
// AgentAuth represents the identity of the Agent itself.
48+
// Independent of 'request.auth.principal' which may be the end user
49+
// credentials or the agent's identity
50+
message AgentAuth {
51+
// The principal of the agent, prefer SPIFFE format of:
52+
// spiffe://<trust-domain>/ns/<project>/sa/<account>
53+
// See: https://spiffe.io/docs/latest/spiffe/concepts/#spiffe-identifiers
54+
string principal = 1;
55+
56+
// Map of string keys to structured claims about the agent.
57+
// For example, with JWT-based tokens, the claims would include fields
58+
// indicating the following:
59+
//
60+
// - The issuer 'iss' (e.g. url of the identity provider)
61+
// - The audience(s) 'aud' (e.g. the intended recipient(s) of the token)
62+
// - The token's expiration time ('exp')
63+
// - The token's subject ('sub')
64+
google.protobuf.Struct claims = 2;
65+
66+
// The OAuth scopes granted to the agent.
67+
// This is a list of strings, where each string is a valid OAuth scope
68+
// (e.g. "https://www.googleapis.com/auth/cloud-platform").
69+
repeated string oauth_scopes = 3;
70+
}
71+
7072
// AgentContext represents the aggregate security and data governance state
7173
// of the agent's context window.
7274
message AgentContext {
@@ -79,36 +81,23 @@ message AgentContext {
7981
// Origin/Lineage tracking.
8082
repeated DataSource data_sources = 3;
8183

82-
// Full conversation history (for deep context inspection).
83-
repeated AgentMessage history = 4;
84-
8584
// The flattened text content of the current prompt.
86-
string prompt = 5;
87-
88-
// Sensitivity describes the classification of data within the context.
89-
message Sensitivity {
90-
// Valid labels are 'pii', 'internal'
91-
string label = 1;
92-
93-
// The optional value associated with the label, e.g. 'credit card'
94-
string value = 2;
95-
}
96-
97-
// Describes the integrity/veracity of the data.
98-
message Trust {
99-
// Valid trust labels are "untrusted" (default), "trusted", and
100-
// "partially_trusted".
101-
string label = 1;
102-
}
103-
104-
// Describes the provenance of a data chunk.
105-
message DataSource {
106-
// Unique id describing the originating data source.
107-
string id = 1; // e.g. "bigquery:sales_table"
85+
string prompt = 4;
86+
}
10887

109-
// The category of origin for this data.
110-
string provenance = 2; // e.g. "UserPrompt", "Database:Secure", "PublicWeb"
111-
}
88+
// AgentHistory represents the ordered sequence of messages representing the
89+
// agent's conversation.
90+
//
91+
// AgentHistory is expected to be provided on-demand via helper methods
92+
// associated with an Agent instance.
93+
message AgentHistory {
94+
// The name of the agent for whom this history is collected.
95+
//
96+
// This should match the `Agent.name` field.
97+
string agent_name = 1;
98+
99+
// The ordered sequence of messages representing the agent's conversation.
100+
repeated AgentMessage messages = 2;
112101
}
113102

114103
// AgentMessage represents a single turn in the conversation.
@@ -120,27 +109,28 @@ message AgentMessage {
120109
// User or System text input.
121110
ContentPart prompt = 1;
122111

123-
// A request to execute a specific tool (MCP).
124-
McpToolCall mcp_call = 2;
125-
126-
// The output/result of a tool execution.
127-
ContentPart result = 3;
112+
// A request to execute a specific tool.
113+
//
114+
// If a call has been completed, the call will have the result or
115+
// error populated. Calls which have not yet been resolved will only have
116+
// the intent (arguments) populated.
117+
ToolCall tool_call = 2;
128118

129119
// A file or multimodal object (Image, PDF).
130-
ContentPart attachment = 4;
131-
132-
// A summary or reference to previous history.
133-
ContentPart history = 5;
120+
ContentPart attachment = 3;
134121

135122
// An error that occurred during processing.
136-
ErrorPart error = 6;
123+
ErrorPart error = 4;
137124
}
138125
}
139126

140127
// The actor who constructed the message (e.g., "user", "model", "tool").
141128
string role = 1;
142129

143130
// The ordered sequence of content parts.
131+
//
132+
// In the case of a tool call, the result or error will be populated within
133+
// the `ToolCall` message rather than split into a separate `Part`.
144134
repeated Part parts = 2;
145135

146136
// Arbitrary metadata associated with the message turn.
@@ -162,16 +152,46 @@ message AgentMessage {
162152
// sensible and with support to type-convert from json to proto perhaps being
163153
// a necessary on-demand feature within agent policies.
164154
message ContentPart {
155+
// Unique identifier for this content part.
165156
string id = 1;
157+
158+
// The type of content.
159+
//
160+
// Common values include: "text", "file", "json"
166161
string type = 2;
162+
163+
// The MIME type of the content.
164+
//
165+
// Common values include: "text/plain", "application/json", "image/png"
167166
string mime_type = 3;
167+
168+
// The name of the content.
168169
string name = 4;
170+
171+
// The description of the content.
169172
string description = 5;
173+
174+
// The URI of the content.
170175
optional string uri = 6;
176+
177+
// The string seriralized representation of the content, either plain text or
178+
// serialized JSON reflected from `structured_content`.
171179
optional string content = 7;
180+
181+
// The binary representation of the content.
182+
//
183+
// This field is used to represent binary data (e.g., images, PDFs) or
184+
// serialized proto messages which come over the wire as base64-encoded string
185+
// values that are expected to be decoded into binary data.
172186
optional bytes data = 8;
187+
188+
// The JSON object representation of the content, if applicable.
173189
optional google.protobuf.Struct structured_content = 9;
190+
191+
// Arbitrary metadata associated with the content part.
174192
optional google.protobuf.Struct annotations = 10;
193+
194+
// Timestamp associated with the content part.
175195
google.protobuf.Timestamp time = 11;
176196
}
177197

@@ -208,19 +228,19 @@ message Model {
208228
string name = 1;
209229
}
210230

211-
// McpToolManifest describes a collection of tools provided by a specific
231+
// ToolManifest describes a collection of tools provided by a specific
212232
// source.
213-
message McpToolManifest {
233+
message ToolManifest {
214234
// Metadata about the tool provider itself, including authorization
215235
// requirements.
216-
McpToolProvider provider = 1;
236+
ToolProvider provider = 1;
217237

218-
// Collection of MCP Tool instances supported by the
219-
repeated McpTool tools = 2;
238+
// Collection of Tool instances specified by the provider.
239+
repeated Tool tools = 2;
220240
}
221241

222-
// McpTool describes a specific function or capability available to the agent.
223-
message McpTool {
242+
// Tool describes a specific function or capability available to the agent.
243+
message Tool {
224244
// The unique name of the tool
225245
string name = 1; // (e.g. "weather_lookup").
226246

@@ -234,14 +254,14 @@ message McpTool {
234254
optional google.protobuf.Struct output_schema = 4;
235255

236256
// Security and behavior hints for policy enforcement.
237-
optional McpToolAnnotations annotations = 5;
257+
optional ToolAnnotations annotations = 5;
238258

239259
// Arbitrary tool metadata.
240260
optional google.protobuf.Struct metadata = 6;
241261
}
242262

243263
// Information about how the tools were provided and by whom.
244-
message McpToolProvider {
264+
message ToolProvider {
245265
// URL where the tools were provided.
246266
string url = 1;
247267

@@ -255,42 +275,96 @@ message McpToolProvider {
255275
repeated string supported_scopes = 4;
256276
}
257277

258-
// Additional properties describing a tool to clients. Derived from MCP Spec.
259-
// See: google/api/configaspects/proto/mcp_config.proto
260-
message McpToolAnnotations {
278+
// Additional properties describing a tool to clients.
279+
//
280+
// Informed by annotations common to the MCP spec and conventions common to
281+
// other agent frameworks.
282+
message ToolAnnotations {
261283
// A human-readable title for the tool.
262284
string title = 1;
263285

286+
// If true, the tool does not modify its environment.
287+
// Default: false
288+
bool read_only = 2;
289+
264290
// If true, the tool may perform destructive updates to its environment.
265291
// If false, the tool performs only additive updates.
266292
// NOTE: This property is meaningful only when `read_only_hint == false`
267-
bool destructive_hint = 2;
293+
bool destructive = 3;
268294

269295
// If true, calling the tool repeatedly with the same arguments will have no
270296
// additional effect on its environment.
271297
// NOTE: This property is meaningful only when `read_only_hint == false`.
272-
bool idempotent_hint = 3;
298+
bool idempotent = 4;
273299

274300
// If true, this tool may interact with an "open world" of external entities.
275301
// If false, the tools domain of interaction is closed. For example, the
276302
// world of a web search tool is open, whereas that of a memory tool is not.
277-
bool open_world_hint = 4;
303+
bool open_world = 5;
278304

279-
// If true, the tool does not modify its environment.
280-
// Default: false
281-
bool read_only_hint = 5;
305+
// If true, this tool is intended to be called asynchronously.
306+
// For example, a tool that starts a simulation process on a server and
307+
// returns immediately.
308+
bool async = 6;
309+
310+
// Additional structured tags associated with the tool.
311+
map<string, google.protobuf.Struct> tags = 7;
312+
313+
// The OAuth scopes required to use this tool. If empty, the set of scopes
314+
// required is inherited from ToolProvider.supported_scopes.
315+
//
316+
// This is a list of strings, where each string is a valid OAuth scope
317+
// (e.g. "https://www.googleapis.com/auth/cloud-platform").
318+
repeated string required_auth_scopes = 8;
319+
320+
// The OAuth scopes that are optional to use this tool.
321+
repeated string optional_auth_scopes = 9;
322+
323+
message DataAccessLevel {
324+
Sensitivity sensitivity = 1;
325+
326+
message AccessRole {
327+
string role = 1;
328+
google.protobuf.Struct metadata = 2;
329+
}
330+
}
331+
}
332+
333+
// Sensitivity describes the classification of data within the context.
334+
message Sensitivity {
335+
// Valid labels are 'pii', 'internal'
336+
string label = 1;
337+
338+
// The optional value associated with the label, e.g. 'credit card'
339+
string value = 2;
340+
}
341+
342+
// Describes the integrity/veracity of the data.
343+
message Trust {
344+
// Valid trust labels are "untrusted" (default), "trusted", and
345+
// "partially_trusted".
346+
string label = 1;
347+
}
348+
349+
// Describes the provenance of a data chunk.
350+
message DataSource {
351+
// Unique id describing the originating data source.
352+
string id = 1; // e.g. "bigquery:sales_table"
353+
354+
// The category of origin for this data.
355+
string provenance = 2; // e.g. "UserPrompt", "Database:Secure", "PublicWeb"
282356
}
283357

284-
// McpToolCall represents a specific invocation of a tool by the agent.
358+
// ToolCall represents a specific invocation of a tool by the agent.
285359
// It captures the intent (arguments), the status (result/error), and
286360
// governance metadata (confirmation).
287-
message McpToolCall {
361+
message ToolCall {
288362
// Unique identifier for this tool call.
289363
// Used to correlate the call with its result or error in the history.
290364
string id = 1;
291365

292366
// The name of the tool being called (e.g., "weather_lookup").
293-
// This should match a tool defined in the agent's McpToolManifest.
367+
// This should match a tool defined in the agent's ToolManifest.
294368
string name = 2;
295369

296370
// The arguments provided to the tool call.

0 commit comments

Comments
 (0)