Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(otel): google adk i/o empty if tool calls are set (#9816)

Nimar3b9c6a4f4785
diff --git a/packages/shared/src/server/otel/OtelIngestionProcessor.ts b/packages/shared/src/server/otel/OtelIngestionProcessor.ts
index baab4c5cce..817a713e9d 100644
--- a/packages/shared/src/server/otel/OtelIngestionProcessor.ts
+++ b/packages/shared/src/server/otel/OtelIngestionProcessor.ts
@@ -1301,6 +1301,15 @@ export class OtelIngestionProcessor {
// Google Vertex AI Agent-Developer-Kit (ADK)
input = attributes["gcp.vertex.agent.llm_request"];
output = attributes["gcp.vertex.agent.llm_response"];
+ // GCP Vertex Agent Tool call input and output
+ // see: https://github.com/google/adk-python/blob/9dce06f9b00259ec42241df4f6638955e783a9d1/src/google/adk/telemetry/tracing.py#L142
+ // Google sets llm_request and llm_response to {} when setting tool_call_args and tool_response
+ if (input === "{}" || !input) {
+ input = attributes["gcp.vertex.agent.tool_call_args"];
+ }
+ if (output === "{}" || !output) {
+ output = attributes["gcp.vertex.agent.tool_response"];
+ }
if (input || output) {
return { input, output, filteredAttributes };
}
@@ -1376,13 +1385,6 @@ export class OtelIngestionProcessor {
return { input, output, filteredAttributes };
}
- // GCP Vertex Agent Tool call input and output
- input = attributes["gcp.vertex.agent.tool_call_args"];
- output = attributes["gcp.vertex.agent.tool_response"];
- if (input || output) {
- return { input, output, filteredAttributes };
- }
-
// TraceLoop uses attributes property
const inputAttributes = Object.keys(attributes).filter((key) =>
key.startsWith("gen_ai.prompt"),
diff --git a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
index 16a41cc45f..8e272eedc6 100644
--- a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
+++ b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
@@ -4542,6 +4542,219 @@ describe("OTel Resource Span Mapping", () => {
).toBe("custom_value");
});
+ it("should extract Google ADK tool call I/O from tool_call_args/tool_response when llm_request/llm_response are empty", async () => {
+ const traceId = "abcdef1234567890abcdef1234567890";
+
+ const googleADKToolSpan = {
+ resource: {
+ attributes: [
+ {
+ key: "telemetry.sdk.language",
+ value: { stringValue: "python" },
+ },
+ {
+ key: "telemetry.sdk.name",
+ value: { stringValue: "opentelemetry" },
+ },
+ {
+ key: "telemetry.sdk.version",
+ value: { stringValue: "1.33.1" },
+ },
+ {
+ key: "langfuse.environment",
+ value: { stringValue: "production" },
+ },
+ {
+ key: "service.name",
+ value: { stringValue: "unknown_service" },
+ },
+ ],
+ },
+ scopeSpans: [
+ {
+ scope: {
+ name: "openinference.instrumentation.google_adk",
+ version: "0.1.6",
+ },
+ spans: [
+ {
+ traceId: Buffer.from(traceId, "hex"),
+ spanId: Buffer.from("89a16f45ba5e6d36", "hex"),
+ parentSpanId: Buffer.from("f55a0bb51dc69634", "hex"),
+ name: "execute_tool_bake_cake",
+ kind: 1,
+ startTimeUnixNano: {
+ low: 310920000,
+ high: 406677085,
+ unsigned: true,
+ },
+ endTimeUnixNano: {
+ low: 858579000,
+ high: 406677085,
+ unsigned: true,
+ },
+ attributes: [
+ {
+ key: "session.id",
+ value: {
+ stringValue: "test-session-333bff8e",
+ },
+ },
+ {
+ key: "user.id",
+ value: { stringValue: "test-user" },
+ },
+ {
+ key: "gen_ai.system",
+ value: { stringValue: "gcp.vertex.agent" },
+ },
+ {
+ key: "gen_ai.operation.name",
+ value: { stringValue: "execute_tool" },
+ },
+ {
+ key: "gen_ai.tool.name",
+ value: { stringValue: "bake_cake" },
+ },
+ {
+ key: "gen_ai.tool.description",
+ value: {
+ stringValue:
+ "a tool that bakes a cake for you, with a lot of chocolate if you ask nicely",
+ },
+ },
+ {
+ key: "gen_ai.tool.call.id",
+ value: {
+ stringValue: "adk-chocolate-caked",
+ },
+ },
+ {
+ key: "gcp.vertex.agent.tool_call_args",
+ value: {
+ stringValue: '{"query": "much duplo"}',
+ },
+ },
+ {
+ key: "gcp.vertex.agent.event_id",
+ value: {
+ stringValue: "some-id",
+ },
+ },
+ {
+ key: "gcp.vertex.agent.tool_response",
+ value: {
+ stringValue: '{"result": "particularly juicy cake"}',
+ },
+ },
+ // These are empty for tool calls in Google ADK - bug trigger
+ {
+ key: "gcp.vertex.agent.llm_request",
+ value: { stringValue: "{}" },
+ },
+ {
+ key: "gcp.vertex.agent.llm_response",
+ value: { stringValue: "{}" },
+ },
+ {
+ key: "tool.name",
+ value: { stringValue: "bake_cake" },
+ },
+ {
+ key: "tool.description",
+ value: {
+ stringValue:
+ "a tool that bakes a cake for you, with a lot of chocolate if you ask nicely",
+ },
+ },
+ {
+ key: "tool.parameters",
+ value: {
+ stringValue: '{"query": "cake type"}',
+ },
+ },
+ {
+ key: "input.value",
+ value: {
+ stringValue: '{"query": "juicy chocolate"}',
+ },
+ },
+ {
+ key: "input.mime_type",
+ value: { stringValue: "application/json" },
+ },
+ {
+ key: "output.value",
+ value: {
+ stringValue:
+ '{"id":"adk-chocolate-caked","name":"bake_cake","response":{"result":"duplo cake"}}',
+ },
+ },
+ {
+ key: "output.mime_type",
+ value: { stringValue: "application/json" },
+ },
+ {
+ key: "openinference.span.kind",
+ value: { stringValue: "TOOL" },
+ },
+ ],
+ events: [],
+ status: { code: 1 },
+ },
+ ],
+ },
+ ],
+ };
+
+ const googleADKEvents = await convertOtelSpanToIngestionEvent(
+ googleADKToolSpan,
+ new Set([traceId]),
+ );
+
+ const toolObservation = googleADKEvents.find(
+ (e) => e.type === "tool-create",
+ );
+
+ // Bug: input/output should NOT be "{}" from empty llm_request/llm_response
+ // Instead, they should come from tool_call_args and tool_response
+ expect(toolObservation?.body.input).not.toBe("{}");
+ expect(toolObservation?.body.output).not.toBe("{}");
+
+ // Verify input is correctly extracted from tool_call_args
+ expect(toolObservation?.body.input).toBe('{"query": "much duplo"}');
+
+ // Verify output is correctly extracted from tool_response
+ expect(toolObservation?.body.output).toBe(
+ '{"result": "particularly juicy cake"}',
+ );
+
+ // Verify Google ADK attributes are NOT in metadata.attributes
+ expect(
+ toolObservation?.body.metadata?.attributes?.[
+ "gcp.vertex.agent.tool_call_args"
+ ],
+ ).toBeUndefined();
+ expect(
+ toolObservation?.body.metadata?.attributes?.[
+ "gcp.vertex.agent.tool_response"
+ ],
+ ).toBeUndefined();
+ expect(
+ toolObservation?.body.metadata?.attributes?.[
+ "gcp.vertex.agent.llm_request"
+ ],
+ ).toBeUndefined();
+ expect(
+ toolObservation?.body.metadata?.attributes?.[
+ "gcp.vertex.agent.llm_response"
+ ],
+ ).toBeUndefined();
+
+ // Verify trace-level attributes
+ expect(toolObservation?.body.traceId).toBe(traceId);
+ });
+
it("should stringify non-string attributes in observation metadata", async () => {
const traceId = "abcdef1234567890abcdef1234567890";