- HTTP request
- Path parameters
- Request body
- Response body
- Authorization scopes
- IAM Permissions
- AgentTrajectory
- Span
- SpanKind
- Event
Writes the execution trajectory of a single agent turn for internal observability logging. This method is used by first-party agent clients (for example, the Gemini Enterprise desktop Cowork agent). Logging is gated on the engine's ObservabilityConfig; content-bearing attributes are redacted unless sensitive-content logging is enabled, and the trajectory is written as a JSON object to a fixed Google-internal GCS bucket for debugging (never to a customer project). It is NOT persisted to the user event or recommendation store.
HTTP request
POST https://discoveryengine.googleapis.com/v1alpha/{parent=projects/*/locations/*/collections/*/engines/*}/agentTrajectories:write
The URL uses gRPC Transcoding syntax.
Path parameters
| Parameters | |
|---|---|
parent |
Required. The |
Request body
The request body contains data with the following structure:
| JSON representation |
|---|
{
"agentTrajectory": {
object ( |
| Fields | |
|---|---|
agentTrajectory |
Required. The agent trajectory to log. |
Response body
Response message for UserEventService.WriteAgentTrajectory method.
If successful, the response body contains data with the following structure:
| JSON representation |
|---|
{ "acceptedSpanCount": integer } |
| Fields | |
|---|---|
acceptedSpanCount |
The number of spans that were accepted for observability logging. |
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/cloud-platformhttps://www.googleapis.com/auth/discoveryengine.assist.readwritehttps://www.googleapis.com/auth/discoveryengine.readwritehttps://www.googleapis.com/auth/discoveryengine.serving.readwrite
For more information, see the Authentication Overview.
IAM Permissions
Requires the following IAM permission on the parent resource:
discoveryengine.engines.createEngineUserData
For more information, see the IAM documentation.
AgentTrajectory
AgentTrajectory captures the execution trace of a single agent turn, modeled on OpenTelemetry GenAI semantic conventions. It is reported by first-party clients (e.g. the Gemini Enterprise desktop Cowork agent) for internal observability logging only; it is not persisted to the user event / recommendation store.
The server gates logging on the engine's ObservabilityConfig, redacts content-bearing attributes unless sensitive-content logging is enabled, and writes the trajectory as a JSON object to a fixed Google-internal GCS bucket for debugging (never to a customer project).
| JSON representation |
|---|
{
"spans": [
{
object ( |
| Fields | |
|---|---|
spans[] |
Required. The spans that make up this agent turn. All spans MUST share the same |
sessionId |
Optional. A unique identifier for the agent session this turn belongs to. |
resourceAttributes |
Optional. Resource-level attributes shared by all spans, following OpenTelemetry resource semantic conventions (e.g. |
Span
A single span within the agent trajectory, aligned with the OpenTelemetry span data model.
| JSON representation |
|---|
{ "traceId": string, "spanId": string, "parentSpanId": string, "displayName": string, "spanKind": enum ( |
| Fields | |
|---|---|
traceId |
Required. A 32 hex-character (16-byte) trace ID shared by all spans of the turn. |
spanId |
Required. A 16 hex-character (8-byte) span ID that uniquely identifies this span within the trace. |
parentSpanId |
Optional. The span ID of this span's parent, if any. Empty for the root span. |
displayName |
Required. A human-readable name for the span (e.g. |
spanKind |
Optional. The kind of the span. |
startTime |
Required. The start time of the span. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: |
endTime |
Required. The end time of the span. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: |
attributes |
Optional. Non-content span attributes following OpenTelemetry GenAI semantic conventions (e.g. |
contentAttributes |
Optional. Content-bearing attributes (e.g. prompts, responses, tool arguments and results). These are opted OUT of observability logging by default and are only logged when the customer has enabled sensitive-content logging. |
status |
Optional. The status of the span. |
events[] |
Optional. Timed events that occurred during the span. |
SpanKind
The kind of the span, aligned with OpenTelemetry SpanKind.
| Enums | |
|---|---|
SPAN_KIND_UNSPECIFIED |
Unspecified. Treated as INTERNAL. |
INTERNAL |
An internal operation within the agent (e.g. invoke_agent). |
SERVER |
A synchronous incoming request handler. |
CLIENT |
A synchronous outgoing request (e.g. a model or tool call). |
PRODUCER |
An asynchronous producer of a message. |
CONSUMER |
An asynchronous consumer of a message. |
Event
A timed event that occurred during the span (e.g. a streamed chunk).
| JSON representation |
|---|
{ "displayName": string, "eventTime": string, "attributes": { string: string, ... } } |
| Fields | |
|---|---|
displayName |
Required. A human-readable name for the event. |
eventTime |
Required. The wall-clock time the event occurred. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: |
attributes |
Optional. Non-content attributes describing the event. |