Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

Remove redundant trace attribute aliases (#4421)

Chad Hietala2359e23a09a6
diff --git a/.changeset/tidy-trace-aliases.md b/.changeset/tidy-trace-aliases.md
new file mode 100644
index 000000000..3fca487c1
--- /dev/null
+++ b/.changeset/tidy-trace-aliases.md
@@ -0,0 +1,6 @@
+---
+"eve": patch
+---
+
+Remove duplicate tool call IDs, error codes, and model provider attributes from agent traces. Runtime context no longer repeats structural channel, session, step, turn, and framework identifiers; trace schema remains version 4.
+Model and activation spans now emit token counts only under `gen_ai.usage.*`; step and tool usage and cost values remain unchanged.
diff --git a/docs/guides/instrumentation/otel.mdx b/docs/guides/instrumentation/otel.mdx
index 02de644b7..33a885475 100644
--- a/docs/guides/instrumentation/otel.mdx
+++ b/docs/guides/instrumentation/otel.mdx
@@ -126,6 +126,10 @@ The resolver receives the channel, session, final model input, step, and turn.
Keys beginning with `eve.` are reserved. Content excluded by
`otel({ tracePolicy })` is not available to the resolver.
+Authored values appear under `ai.settings.context.*`. Framework channel, session,
+step, turn, and version identifiers use structural span attributes instead of
+runtime-context copies. `ai.settings.context.eve.environment` remains available.
+
## Trace topology
OpenTelemetry destinations receive the following trace topology for an ordinary
@@ -145,6 +149,14 @@ context, the first subagent turn starts a new trace. Later turns in the child
session start new traces. They do not use the original dispatch span as their
parent.
+Use `gen_ai.tool.call.id` to correlate tool and approval spans. Tool failures use
+`error.type`. These attributes replace the duplicate `agent.action.call_id` and
+`agent.action.error.code` fields without changing trace schema version 4.
+
+Model and activation spans record token counts under `gen_ai.usage.*`, without
+duplicate `agent.usage.*` token fields. Step and tool spans retain `agent.usage.*`.
+Cost values remain unchanged.
+
A remote child starts a separate trace with a root `invoke_agent` span. Its first
turn links to the caller with `eve.link.type=agent.dispatch`. The receiving
deployment applies its sampler. Queries for local dispatches must use
diff --git a/packages/eve/src/cli/commands/trace-detail.test.ts b/packages/eve/src/cli/commands/trace-detail.test.ts
index 25f5807a3..cb1064ef1 100644
--- a/packages/eve/src/cli/commands/trace-detail.test.ts
+++ b/packages/eve/src/cli/commands/trace-detail.test.ts
@@ -44,7 +44,13 @@ describe("spanMetricChips", () => {
it("prefers gateway cost over provider cost and parses string ints", () => {
expect(
spanMetricChips(
- span({ attributes: { "gen_ai.usage.cost": 0.5, "agent.usage.input_tokens": "900" } }),
+ span({
+ attributes: {
+ "gen_ai.operation.name": "chat",
+ "gen_ai.usage.cost": 0.5,
+ "gen_ai.usage.input_tokens": "900",
+ },
+ }),
),
).toEqual(["↑900", "$0.5000"]);
});
diff --git a/packages/eve/src/cli/commands/trace-detail.ts b/packages/eve/src/cli/commands/trace-detail.ts
index aec21ca4e..b243e7a92 100644
--- a/packages/eve/src/cli/commands/trace-detail.ts
+++ b/packages/eve/src/cli/commands/trace-detail.ts
@@ -20,8 +20,11 @@ import { localTraceSpanCostUsd, type LocalTraceSummary } from "#tracing/local-tr
*/
export function spanMetricChips(span: LocalTraceSpan): string[] {
const chips: string[] = [];
- const input = numberAttribute(span, "agent.usage.input_tokens");
- const output = numberAttribute(span, "agent.usage.output_tokens");
+ const operation = span.attributes["gen_ai.operation.name"];
+ const usagePrefix =
+ operation === "chat" || operation === "invoke_agent" ? "gen_ai.usage" : "agent.usage";
+ const input = numberAttribute(span, `${usagePrefix}.input_tokens`);
+ const output = numberAttribute(span, `${usagePrefix}.output_tokens`);
if (input !== undefined) chips.push(`↑${formatCompactTokenCount(input)}`);
if (output !== undefined) chips.push(`↓${formatCompactTokenCount(output)}`);
const cost = localTraceSpanCostUsd(span);
diff --git a/packages/eve/src/cli/dev/tui/traces/trace-conversation.test.ts b/packages/eve/src/cli/dev/tui/traces/trace-conversation.test.ts
index cbfe66238..1cd1a2053 100644
--- a/packages/eve/src/cli/dev/tui/traces/trace-conversation.test.ts
+++ b/packages/eve/src/cli/dev/tui/traces/trace-conversation.test.ts
@@ -58,8 +58,8 @@ function weatherTurn(): LocalTraceSpan[] {
"gen_ai.request.model": "claude-test",
"gen_ai.input.messages": messages,
"ai.response.text": "Let me check.",
- "agent.usage.input_tokens": 6200,
- "agent.usage.output_tokens": 50,
+ "gen_ai.usage.input_tokens": 6200,
+ "gen_ai.usage.output_tokens": 50,
});
const action = span("d".repeat(16), "agent.action", 2100, 2400, turn.spanId, {
"agent.action.name": "get_weather",
@@ -158,7 +158,7 @@ describe("buildConversationItems", () => {
},
}));
const parentAction = span("e".repeat(16), "agent.action", 5900, 6000, parent[0]!.spanId, {
- "agent.action.call_id": "call-7",
+ "gen_ai.tool.call.id": "call-7",
"agent.action.kind": "subagent-call",
"agent.action.name": "echo-marker",
"agent.turn.id": "turn_0",
@@ -238,8 +238,9 @@ describe("buildConversationItems", () => {
]),
"ai.response.text": "Dispatching.",
});
- const parentAction = span("e".repeat(16), "agent.action", 20, 30, step1.spanId, {
- "agent.action.call_id": "call-1",
+ const parentAction = span("e".repeat(16), "execute_tool echo-marker", 20, 30, step1.spanId, {
+ "gen_ai.operation.name": "execute_tool",
+ "gen_ai.tool.call.id": "call-1",
"agent.action.kind": "subagent-call",
"agent.action.name": "echo-marker",
"agent.turn.id": "turn_0",
@@ -313,15 +314,15 @@ describe("buildConversationItems", () => {
expect(items[0]?.error).toBe(true);
});
- it("keeps model spans that carry only token usage", () => {
+ it("keeps model spans that carry only standard token usage", () => {
const turn = span("a".repeat(16), "agent.turn", 0, 0, undefined, {});
const step = span("b".repeat(16), "agent.step", 10, 5000, turn.spanId, {});
const model = span("c".repeat(16), "ai.streamText.doStream", 20, 2000, step.spanId, {
"gen_ai.input.messages": JSON.stringify([
{ parts: [{ content: "hi", type: "text" }], role: "user" },
]),
- "agent.usage.input_tokens": 100,
- "agent.usage.output_tokens": 10,
+ "gen_ai.usage.input_tokens": 100,
+ "gen_ai.usage.output_tokens": 10,
});
const items = buildConversationItems(trace([turn, step, model]));
expect(items.map((item) => item.kind)).toEqual(["assistant"]);
@@ -335,7 +336,7 @@ describe("buildConversationItems", () => {
"gen_ai.input.messages": JSON.stringify([
{ parts: [{ content: "hi", type: "text" }], role: "user" },
]),
- "agent.usage.input_tokens": 10,
+ "gen_ai.usage.input_tokens": 10,
});
const action = span(
"d".repeat(16),
@@ -425,7 +426,7 @@ describe("renderConversationItem", () => {
{ parts: [{ content: "hi", type: "text" }], role: "user" },
]),
"ai.response.text": "reply",
- "agent.usage.input_tokens": 100,
+ "gen_ai.usage.input_tokens": 100,
});
const assistant = buildConversationItems(trace([turn, step, model])).find(
(item) => item.kind === "assistant",
diff --git a/packages/eve/src/cli/dev/tui/traces/trace-conversation.ts b/packages/eve/src/cli/dev/tui/traces/trace-conversation.ts
index 0364d7a56..d4320aa00 100644
--- a/packages/eve/src/cli/dev/tui/traces/trace-conversation.ts
+++ b/packages/eve/src/cli/dev/tui/traces/trace-conversation.ts
@@ -12,6 +12,7 @@ import type { LocalTrace, LocalTraceSpan } from "#tracing/local-trace-reader.js"
import { compareLocalTraceSpans, isAgentTurnSpan } from "#tracing/local-trace-reader.js";
import { agentTurnIdentity } from "#tracing/agent-span-contract.js";
import { localTraceSpanCostUsd } from "#tracing/local-trace-summary.js";
+import { traceStringAttribute } from "#tracing/local-trace-operations.js";
import { formatCompactTokenCount } from "../stream-format.js";
import type { Theme } from "../theme.js";
@@ -114,9 +115,9 @@ export function buildConversationItems(trace: LocalTrace): ConversationItem[] {
if (isModelSpan(span)) {
const text = stringAttribute(span, "ai.response.text");
const reasoning = stringAttribute(span, "ai.response.reasoning");
- const hasUsage =
- numberAttribute(span, "agent.usage.input_tokens") !== undefined ||
- numberAttribute(span, "agent.usage.output_tokens") !== undefined;
+ const inputTokens = numberAttribute(span, "gen_ai.usage.input_tokens");
+ const outputTokens = numberAttribute(span, "gen_ai.usage.output_tokens");
+ const hasUsage = inputTokens !== undefined || outputTokens !== undefined;
const hasToolCalls = span.attributes["ai.response.tool_calls"] !== undefined;
const isEmpty =
(text === undefined || text.trim().length === 0) &&
@@ -131,9 +132,9 @@ export function buildConversationItems(trace: LocalTrace): ConversationItem[] {
costUsd: stepCostUsd(span, byId),
durationMs: spanDurationMs(span),
error: span.statusCode === 2,
- inputTokens: numberAttribute(span, "agent.usage.input_tokens"),
+ inputTokens,
model: stringAttribute(span, "gen_ai.request.model"),
- outputTokens: numberAttribute(span, "agent.usage.output_tokens"),
+ outputTokens,
reasoning,
span,
subagent,
@@ -253,7 +254,7 @@ function turnSubagent(
const name = stringAttribute(parent, "agent.action.name");
return {
name: name === undefined ? undefined : stripTerminalControls(name),
- parentCallId: stringAttribute(parent, "agent.action.call_id"),
+ parentCallId: traceStringAttribute(parent, "gen_ai.tool.call.id"),
parentTurnId,
};
}
diff --git a/packages/eve/src/harness/model-call/call.ts b/packages/eve/src/harness/model-call/call.ts
index dae2d3dca..6f3e0818a 100644
--- a/packages/eve/src/harness/model-call/call.ts
+++ b/packages/eve/src/harness/model-call/call.ts
@@ -57,7 +57,6 @@ import {
} from "#harness/turn-tag-state.js";
import type { StepResult } from "#harness/types.js";
import type { InstrumentationAttempt } from "#instrumentation/runtime.js";
-import { resolveInstalledPackageInfo } from "#internal/application/package.js";
import { createLogger, logError } from "#internal/logging.js";
import { maybeCompact } from "#harness/compaction/step.js";
import { buildGatewayAttributionHeaders } from "./model.js";
@@ -79,7 +78,6 @@ import { logToolExecutionError, type ModelTools, prepareModelTools } from "./too
import { extractGatewayCostUsd, extractTokenUsageDelta } from "./usage.js";
const environment = process.env.NODE_ENV ?? "unknown";
-const eveVersion = resolveInstalledPackageInfo().version;
const log = createLogger("harness.tool-loop");
@@ -311,7 +309,6 @@ export class ModelCaller {
step.instrumentation?.resolveRuntimeContext({
emissionState: step.position(),
environment,
- eveVersion,
modelInput: { instructions, messages: this.modelMessages },
session: step.session,
}) ?? {};
diff --git a/packages/eve/src/harness/tool-loop.test.ts b/packages/eve/src/harness/tool-loop.test.ts
index cefdd7e26..9eb215570 100644
--- a/packages/eve/src/harness/tool-loop.test.ts
+++ b/packages/eve/src/harness/tool-loop.test.ts
@@ -9930,7 +9930,7 @@ describe("createToolLoopHarness", () => {
}
});
- it("injects eve.version alongside session context when runtimeContext is configured", async () => {
+ it("retains environment context when runtimeContext returns no values", async () => {
setupMockAgent({
finishReason: "stop",
response: { messages: [{ content: "Hello!", role: "assistant" }] },
@@ -9950,10 +9950,7 @@ describe("createToolLoopHarness", () => {
telemetry?: { integrations?: unknown; isEnabled?: boolean };
};
const runtimeContext = agentCall?.runtimeContext;
- expect(runtimeContext).toBeDefined();
- expect(runtimeContext?.["eve.version"]).toEqual(expect.any(String));
- expect(runtimeContext?.["eve.version"]).not.toBe("");
- expect(runtimeContext?.["eve.session.id"]).toBe("test-session");
+ expect(runtimeContext).toEqual({ "eve.environment": "test" });
expect(agentCall?.telemetry?.isEnabled).toBe(true);
expect(agentCall?.telemetry?.integrations).toEqual([
mockCreateAiSdkHookBridge.mock.results[0]!.value,
@@ -10245,16 +10242,11 @@ describe("createToolLoopHarness", () => {
turn: { id: "turn_0", sequence: 0 },
}),
);
- expect(agentCall?.runtimeContext).toMatchObject({
- "eve.channel.kind": "channel:support",
- "eve.session.id": "test-session",
- "eve.step.index": "0",
- "eve.turn.id": "turn_0",
- "eve.turn.sequence": "0",
+ expect(agentCall?.runtimeContext).toEqual({
+ "eve.environment": "test",
"slack.user_id": "U123",
"turn.id": "turn_0",
});
- expect(agentCall?.runtimeContext?.["eve.version"]).toEqual(expect.any(String));
expect(agentCall?.telemetry?.includeRuntimeContext).toEqual(
Object.fromEntries(Object.keys(agentCall?.runtimeContext ?? {}).map((key) => [key, true])),
);
@@ -10304,8 +10296,8 @@ describe("createToolLoopHarness", () => {
const agentCall = vi.mocked(ToolLoopAgent).mock.calls[0]?.[0] as {
runtimeContext?: Record<string, unknown>;
};
- expect(agentCall?.runtimeContext).toMatchObject({
- "eve.session.id": "test-session",
+ expect(agentCall?.runtimeContext).toEqual({
+ "eve.environment": "test",
});
expect(logs.records).toContainEqual(
expect.objectContaining({
diff --git a/packages/eve/src/instrumentation/runtime-context.test.ts b/packages/eve/src/instrumentation/runtime-context.test.ts
index 25ee7b83d..de0bf4eb8 100644
--- a/packages/eve/src/instrumentation/runtime-context.test.ts
+++ b/packages/eve/src/instrumentation/runtime-context.test.ts
@@ -35,13 +35,7 @@ const emissionState: TurnPosition = {
const messages: readonly ModelMessage[] = [{ content: "hello", role: "user" }];
const FRAMEWORK_KEYS = {
- "eve.channel.kind": "unknown",
"eve.environment": "test",
- "eve.session.id": "test-session",
- "eve.step.index": "1",
- "eve.turn.id": "turn_2",
- "eve.turn.sequence": "2",
- "eve.version": "0.0.0-test",
};
function build(
@@ -49,7 +43,6 @@ function build(
): Record<string, unknown> | undefined {
return buildTelemetryRuntimeContext({
capturesContent: false,
- eveVersion: "0.0.0-test",
emissionState,
environment: "test",
modelInput: { instructions: undefined, messages },
@@ -64,11 +57,11 @@ describe("buildTelemetryRuntimeContext", () => {
expect(build({ providerResolvers: undefined })).toBeUndefined();
});
- it("emits framework identifiers when no resolver is configured", () => {
+ it("emits only environment context when the resolver returns no values", () => {
expect(build()).toEqual(FRAMEWORK_KEYS);
});
- it("reflects the active channel kind and exposes channel metadata to the resolver", () => {
+ it("exposes the active channel kind and metadata to the resolver", () => {
const ctx = new ContextContainer();
const resolver: RuntimeContextResolver = (input) => {
if (input.channel.kind !== "channel:support") return undefined;
@@ -90,8 +83,8 @@ describe("buildTelemetryRuntimeContext", () => {
}),
);
- expect(runtimeContext).toMatchObject({
- "eve.channel.kind": "channel:support",
+ expect(runtimeContext).toEqual({
+ "eve.environment": "test",
"slack.user_id": "U999",
});
});
diff --git a/packages/eve/src/instrumentation/runtime-context.ts b/packages/eve/src/instrumentation/runtime-context.ts
index 9107430b1..1cd5d2fba 100644
--- a/packages/eve/src/instrumentation/runtime-context.ts
+++ b/packages/eve/src/instrumentation/runtime-context.ts
@@ -33,7 +33,6 @@ const log = createLogger("harness.instrumentation-runtime-context");
export interface BuildTelemetryRuntimeContextInput {
readonly capturesContent: boolean;
readonly context?: InstrumentationRuntimeContextSnapshot;
- readonly eveVersion: string;
readonly emissionState: TurnPosition;
readonly environment: string;
readonly modelInput: {
@@ -86,23 +85,15 @@ export function buildTelemetryRuntimeContext(
}
const providerRuntimeContext = resolveProviderRuntimeContext(input);
- const context = input.context ?? snapshotInstrumentationRuntimeContext(contextStorage.getStore());
- const projection = context.channel;
return {
...providerRuntimeContext,
- "eve.channel.kind": normalizeInstrumentationChannelKind(projection?.kind),
"eve.environment": input.environment,
- "eve.session.id": input.session.sessionId,
- "eve.step.index": String(input.emissionState.stepIndex),
- "eve.turn.id": input.emissionState.turnId,
- "eve.turn.sequence": String(input.emissionState.sequence),
- "eve.version": input.eveVersion,
};
}
function buildInstrumentationStepStartedInput(
- input: Omit<BuildTelemetryRuntimeContextInput, "eveVersion" | "environment">,
+ input: Omit<BuildTelemetryRuntimeContextInput, "environment">,
): InstrumentationStepStartedEventInput {
const context = input.context ?? snapshotInstrumentationRuntimeContext(contextStorage.getStore());
const projection = context.channel;
diff --git a/packages/eve/src/instrumentation/runtime.test.ts b/packages/eve/src/instrumentation/runtime.test.ts
index bad8b25c1..5823478e6 100644
--- a/packages/eve/src/instrumentation/runtime.test.ts
+++ b/packages/eve/src/instrumentation/runtime.test.ts
@@ -271,7 +271,6 @@ describe("initializeSessionInstrumentation", () => {
},
async (scope) =>
scope.resolveRuntimeContext({
- eveVersion: "0.0.0",
emissionState: { sessionStarted: true, sequence: 0, stepIndex: 0, turnId: "turn-1" },
environment: "test",
modelInput: {
@@ -807,7 +806,6 @@ describe("bindInstrumentationRuntime", () => {
};
const readScopedState = (scope: InstrumentationStepScope<{ sessionId: string }>) => ({
messageCount: scope.resolveRuntimeContext({
- eveVersion: "0.0.0",
emissionState: { sessionStarted: true, sequence: 0, stepIndex: 0, turnId: "turn-1" },
environment: "test",
modelInput: { instructions: undefined, messages: [{ content: "secret", role: "user" }] },
diff --git a/packages/eve/src/tracing/agent-approval-instrumentation.ts b/packages/eve/src/tracing/agent-approval-instrumentation.ts
index d922c9909..071b70fe9 100644
--- a/packages/eve/src/tracing/agent-approval-instrumentation.ts
+++ b/packages/eve/src/tracing/agent-approval-instrumentation.ts
@@ -100,7 +100,7 @@ export function createAgentApprovalInstrumentation(input: {
AGENT_SPAN_NAMES.approval,
{
attributes: {
- "agent.action.call_id": state.actionCallId,
+ "gen_ai.tool.call.id": state.actionCallId,
"agent.action.name": state.actionName,
"agent.approval.kind": "tool-approval",
"agent.approval.outcome": event.outcome,
diff --git a/packages/eve/src/tracing/agent-otel-provider.test.ts b/packages/eve/src/tracing/agent-otel-provider.test.ts
index efeef6c74..09792f1d4 100644
--- a/packages/eve/src/tracing/agent-otel-provider.test.ts
+++ b/packages/eve/src/tracing/agent-otel-provider.test.ts
@@ -1470,8 +1470,8 @@ describe("createAgentOtelInstrumentation", () => {
expect(turn.kind).toBe(SpanKind.INTERNAL);
expect(turn.attributes).toMatchObject({
"agent.name": "weather",
- "agent.usage.input_tokens": 10,
- "agent.usage.output_tokens": 5,
+ "gen_ai.usage.input_tokens": 10,
+ "gen_ai.usage.output_tokens": 5,
"gen_ai.agent.name": "weather",
"gen_ai.conversation.id": "session-1",
"gen_ai.operation.name": "invoke_agent",
@@ -1481,12 +1481,12 @@ describe("createAgentOtelInstrumentation", () => {
expect(step.attributes).toMatchObject({
"agent.framework.name": "eve",
"agent.model.id": "claude-test",
- "agent.model.provider": "anthropic",
"agent.usage.cache_read_tokens": 4,
"agent.usage.cache_write_tokens": 2,
"agent.usage.input_tokens": 10,
"agent.usage.output_tokens": 5,
});
+ expect(step.attributes).not.toHaveProperty("agent.model.provider");
expect(model.attributes).toMatchObject({
"gen_ai.response.id": "response-1",
"gen_ai.response.model": "claude-response",
@@ -1495,6 +1495,16 @@ describe("createAgentOtelInstrumentation", () => {
"gen_ai.usage.input_tokens": 10,
"gen_ai.usage.output_tokens": 5,
});
+ for (const span of [turn, model]) {
+ for (const key of [
+ "agent.usage.input_tokens",
+ "agent.usage.output_tokens",
+ "agent.usage.cache_read_tokens",
+ "agent.usage.cache_write_tokens",
+ ]) {
+ expect(span.attributes).not.toHaveProperty(key);
+ }
+ }
expect(tool.attributes).toMatchObject({
"agent.action.kind": "tool-call",
"agent.action.name": "weather",
@@ -1626,7 +1636,7 @@ describe("createAgentOtelInstrumentation", () => {
const actions = runtime!.exporter
.getFinishedSpans()
.filter((span) => span.attributes["gen_ai.operation.name"] === "execute_tool");
- expect(actions.map((span) => span.attributes["agent.action.call_id"]).sort()).toEqual([
+ expect(actions.map((span) => span.attributes["gen_ai.tool.call.id"]).sort()).toEqual([
"wait",
"workflow",
]);
@@ -1905,7 +1915,7 @@ describe("createAgentOtelInstrumentation", () => {
hooks: runtime.hooks,
runInContext: runtime.runInContext,
runtimeContext: {
- "eve.session.id": "session-1",
+ "eve.environment": "production",
"posthog.distinct_id": "user-123",
nested: { ignored: undefined, team: "platform" },
tags: ["a", "b"],
@@ -1921,7 +1931,7 @@ describe("createAgentOtelInstrumentation", () => {
const model = byName(spans, "chat claude-test")[0]!;
for (const span of [step, model]) {
expect(span.attributes).toMatchObject({
- "ai.settings.context.eve.session.id": "session-1",
+ "ai.settings.context.eve.environment": "production",
"ai.settings.context.posthog.distinct_id": "user-123",
"ai.settings.context.nested.team": "platform",
"ai.settings.context.tags": ["a", "b"],
@@ -2240,10 +2250,12 @@ describe("createAgentOtelInstrumentation", () => {
const spans = replacement.exporter.getFinishedSpans();
const approval = byName(spans, "agent.approval")[0]!;
const action = byName(spans, "execute_tool weather")[0]!;
+ expect(approval.attributes).not.toHaveProperty("agent.action.call_id");
+ expect(action.attributes).not.toHaveProperty("agent.action.call_id");
expect(approval.parentSpanContext?.spanId).toBe(action.spanContext().spanId);
expect(approval.status.code).toBe(SpanStatusCode.UNSET);
expect(approval.attributes).toMatchObject({
- "agent.action.call_id": "tool-1",
+ "gen_ai.tool.call.id": "tool-1",
"agent.action.name": "weather",
"agent.approval.kind": "tool-approval",
"agent.approval.outcome": "approved",
@@ -2596,12 +2608,12 @@ describe("createAgentOtelInstrumentation", () => {
await runtime.provider.forceFlush();
return runtime.exporter
.getFinishedSpans()
- .find((span) => span.attributes["agent.action.call_id"] !== undefined)!;
+ .find((span) => span.attributes["gen_ai.tool.call.id"] !== undefined)!;
};
const recorded = await run(createRuntime(), "recorded");
+ expect(recorded.attributes).not.toHaveProperty("agent.action.error.code");
expect(recorded.attributes).toMatchObject({
- "agent.action.error.code": "PUBLISH_FAILED",
"agent.action.outcome": "failed",
"error.type": "PUBLISH_FAILED",
});
@@ -2628,7 +2640,6 @@ describe("createAgentOtelInstrumentation", () => {
"redacted",
);
expect(redacted.attributes).toMatchObject({
- "agent.action.error.code": "PUBLISH_FAILED",
"agent.action.outcome": "failed",
"error.type": "PUBLISH_FAILED",
});
@@ -3324,7 +3335,6 @@ describe("createAgentOtelInstrumentation", () => {
const action = byName(spans, "execute_tool weather")[0]!;
expect(action.status.code).toBe(SpanStatusCode.ERROR);
expect(action.attributes).toMatchObject({
- "agent.action.error.code": "TOOL_CALL_FAILED",
"agent.action.outcome": "failed",
"error.type": "TOOL_CALL_FAILED",
});
diff --git a/packages/eve/src/tracing/agent-otel-provider.ts b/packages/eve/src/tracing/agent-otel-provider.ts
index d5d55325b..3b9a24369 100644
--- a/packages/eve/src/tracing/agent-otel-provider.ts
+++ b/packages/eve/src/tracing/agent-otel-provider.ts
@@ -361,7 +361,6 @@ export function createAgentOtelInstrumentation(
const attempt = steps.get(event.scope);
if (attempt === undefined) return;
attempt.span.setAttribute("agent.model.id", event.model.modelId);
- attempt.span.setAttribute("agent.model.provider", event.model.provider);
const span = input.tracer.startSpan(
modelSpanName(event.model.modelId),
{
diff --git a/packages/eve/src/tracing/agent-otel-usage.ts b/packages/eve/src/tracing/agent-otel-usage.ts
index 7d4248f02..1c136dacc 100644
--- a/packages/eve/src/tracing/agent-otel-usage.ts
+++ b/packages/eve/src/tracing/agent-otel-usage.ts
@@ -24,9 +24,11 @@ export function setAgentUsage(span: Span, usage: InstrumentationUsage): void {
}
}
-/** Applies standard GenAI token usage while retaining eve's compatibility attributes. */
+/** Applies standard GenAI token usage and retains eve's cost attribute. */
export function setGenAiUsage(span: Span, usage: InstrumentationUsage): void {
- setAgentUsage(span, usage);
+ if (usage.costUsd !== undefined) {
+ span.setAttribute(AGENT_USAGE_ATTRIBUTES.costUsd, usage.costUsd);
+ }
if (usage.inputTokens !== undefined) {
span.setAttribute("gen_ai.usage.input_tokens", usage.inputTokens);
}
diff --git a/packages/eve/src/tracing/agent-telemetry-contract.integration.test.ts b/packages/eve/src/tracing/agent-telemetry-contract.integration.test.ts
index 7361e32be..81fec5364 100644
--- a/packages/eve/src/tracing/agent-telemetry-contract.integration.test.ts
+++ b/packages/eve/src/tracing/agent-telemetry-contract.integration.test.ts
@@ -261,9 +261,9 @@ describe("exported agent telemetry contract", () => {
.getFinishedSpans()
.filter((span) => span.attributes["gen_ai.operation.name"] === "execute_tool");
expect(actions).toHaveLength(2);
- const outer = actions.find((span) => span.attributes["agent.action.call_id"] === "call-1")!;
+ const outer = actions.find((span) => span.attributes["gen_ai.tool.call.id"] === "call-1")!;
const nested = actions.find(
- (span) => span.attributes["agent.action.call_id"] === "call-1:1",
+ (span) => span.attributes["gen_ai.tool.call.id"] === "call-1:1",
)!;
expect(outer.attributes["agent.action.kind"]).toBe("tool-call");
expect(nested.parentSpanContext?.spanId).toBe(outer.spanContext().spanId);
@@ -284,7 +284,7 @@ describe("exported agent telemetry contract", () => {
);
const metadataNested = runtime.metadata
.getFinishedSpans()
- .find((span) => span.attributes["agent.action.call_id"] === "call-1:1")!;
+ .find((span) => span.attributes["gen_ai.tool.call.id"] === "call-1:1")!;
expect(metadataNested.attributes).not.toHaveProperty("gen_ai.tool.call.arguments");
} finally {
await runtime.shutdown();
@@ -1118,7 +1118,7 @@ describe("exported agent telemetry contract", () => {
const workflow = parsed.find(
(span) =>
span.attributes["gen_ai.operation.name"] === "execute_tool" &&
- span.attributes["agent.action.call_id"] === "workflow",
+ span.attributes["gen_ai.tool.call.id"] === "workflow",
)!;
const activation = parsed.find(
(span) => span.name === "invoke_agent child" && isAgentTurnSpan(span),
@@ -1139,8 +1139,6 @@ describe("exported agent telemetry contract", () => {
"agent.run.id": "child",
"gen_ai.usage.input_tokens": 10,
"gen_ai.usage.output_tokens": 5,
- "agent.usage.input_tokens": 10,
- "agent.usage.output_tokens": 5,
});
expect(normalizeTraceForest(parsed, exported)).toEqual([
"conversation original-conversation",
diff --git a/packages/eve/src/tracing/agent-tool-instrumentation.ts b/packages/eve/src/tracing/agent-tool-instrumentation.ts
index 5231727e7..8b5250e46 100644
--- a/packages/eve/src/tracing/agent-tool-instrumentation.ts
+++ b/packages/eve/src/tracing/agent-tool-instrumentation.ts
@@ -170,8 +170,6 @@ export function createAgentToolInstrumentation(input: {
);
if (event.usage !== undefined) setAgentUsage(span, event.usage);
if (event.type === "tool.call.failed") {
- if (event.errorCode !== undefined)
- span.setAttribute("agent.action.error.code", event.errorCode);
recordToolError(span, event.error, event.errorCode);
} else if (event.output.type === "error") {
recordToolError(span, event.output.error);
@@ -204,7 +202,6 @@ export function createAgentToolInstrumentation(input: {
`execute_tool ${state.name}`,
{
attributes: {
- "agent.action.call_id": state.callId,
"agent.action.kind": state.kind,
"agent.action.name": state.name,
...(state.parentCallId === undefined
diff --git a/packages/eve/src/tracing/invoke-tool-parity.integration.test.ts b/packages/eve/src/tracing/invoke-tool-parity.integration.test.ts
index 29b0ea64e..5ad588cc1 100644
--- a/packages/eve/src/tracing/invoke-tool-parity.integration.test.ts
+++ b/packages/eve/src/tracing/invoke-tool-parity.integration.test.ts
@@ -56,11 +56,9 @@ const ALLOWED_ATTRIBUTE_DIFFERENCES = new Set([
"eve.tool.invocation",
"eve.tool.outcome",
// Durable calls carry the accepted action's identity and lifecycle metadata.
- "agent.action.call_id",
"agent.action.kind",
"agent.action.name",
"agent.action.outcome",
- "agent.action.error.code",
// Accepted failures use the durable error code; direct failures retain the thrown type.
"error.type",
"agent.framework.name",
diff --git a/packages/eve/src/tracing/local-trace-analysis.test.ts b/packages/eve/src/tracing/local-trace-analysis.test.ts
index 3366a3b3d..66b5144f3 100644
--- a/packages/eve/src/tracing/local-trace-analysis.test.ts
+++ b/packages/eve/src/tracing/local-trace-analysis.test.ts
@@ -87,7 +87,7 @@ describe("analyzeLocalTrace", () => {
attributes: {
"agent.action.kind": "tool-call",
"agent.action.name": "read_file",
- "agent.action.call_id": "call-1",
+ "gen_ai.tool.call.id": "call-1",
"agent.session.id": "target",
"agent.turn.id": "turn-1",
},
@@ -168,14 +168,14 @@ describe("analyzeLocalTrace", () => {
]);
});
- it("reports per-model token usage without inventing missing metrics", () => {
+ it("reports standard per-model token usage without inventing missing metrics", () => {
const model = span({
attributes: {
"gen_ai.operation.name": "chat",
- "agent.usage.input_tokens": 100,
- "agent.usage.output_tokens": 10,
- "agent.usage.cache_read_tokens": 80,
- "agent.usage.cache_write_tokens": 0,
+ "gen_ai.usage.input_tokens": 100,
+ "gen_ai.usage.output_tokens": 10,
+ "gen_ai.usage.cache_read.input_tokens": 80,
+ "gen_ai.usage.cache_write.input_tokens": 0,
},
endMs: 10,
name: "chat test-model",
@@ -187,15 +187,15 @@ describe("analyzeLocalTrace", () => {
{
...model,
name: "invoke_agent",
- attributes: { "agent.usage.input_tokens": 100 },
+ attributes: { "gen_ai.usage.input_tokens": 100 },
spanId: "b".repeat(16),
},
{
...model,
attributes: {
"gen_ai.operation.name": "chat",
- "agent.usage.input_tokens": -1,
- "agent.usage.output_tokens": Infinity,
+ "gen_ai.usage.input_tokens": -1,
+ "gen_ai.usage.output_tokens": Infinity,
},
spanId: "c".repeat(16),
},
diff --git a/packages/eve/src/tracing/local-trace-analysis.ts b/packages/eve/src/tracing/local-trace-analysis.ts
index e58f9aec3..4ca813b18 100644
--- a/packages/eve/src/tracing/local-trace-analysis.ts
+++ b/packages/eve/src/tracing/local-trace-analysis.ts
@@ -119,9 +119,7 @@ function recordFor(operation: LocalTraceOperation, startTimeNs: bigint): TraceTi
spanId: span.spanId,
startOffsetMs: Number(span.startTimeNs - startTimeNs) / 1_000_000,
};
- const callId =
- traceStringAttribute(span, "gen_ai.tool.call.id") ??
- traceStringAttribute(span, "agent.action.call_id");
+ const callId = traceStringAttribute(span, "gen_ai.tool.call.id");
const model = traceModelName(span);
const sessionId = traceSessionId(span);
const name = traceToolName(span);
@@ -139,10 +137,10 @@ function recordFor(operation: LocalTraceOperation, startTimeNs: bigint): TraceTi
if (category === "model") {
const usage: Mutable<TraceTokenUsage> = {};
for (const [field, attribute] of Object.entries({
- inputTokens: "agent.usage.input_tokens",
- outputTokens: "agent.usage.output_tokens",
- cacheReadTokens: "agent.usage.cache_read_tokens",
- cacheWriteTokens: "agent.usage.cache_write_tokens",
+ inputTokens: "gen_ai.usage.input_tokens",
+ outputTokens: "gen_ai.usage.output_tokens",
+ cacheReadTokens: "gen_ai.usage.cache_read.input_tokens",
+ cacheWriteTokens: "gen_ai.usage.cache_write.input_tokens",
})) {
const value = span.attributes[attribute];
if (typeof value === "number" && Number.isFinite(value) && value >= 0) {
diff --git a/packages/eve/src/tracing/local-trace-summary.test.ts b/packages/eve/src/tracing/local-trace-summary.test.ts
index 862720037..2f7cd2f96 100644
--- a/packages/eve/src/tracing/local-trace-summary.test.ts
+++ b/packages/eve/src/tracing/local-trace-summary.test.ts
@@ -39,8 +39,8 @@ describe("summarizeLocalTrace", () => {
name: "ai.streamText.doStream",
attributes: {
"gen_ai.operation.name": "chat",
- "agent.usage.input_tokens": 1000,
- "agent.usage.output_tokens": 100,
+ "gen_ai.usage.input_tokens": 1000,
+ "gen_ai.usage.output_tokens": 100,
"gen_ai.request.model": "gpt-5",
},
}),
diff --git a/packages/eve/test/tui-client/tui-traces.ts b/packages/eve/test/tui-client/tui-traces.ts
index b1253fe5b..033cb36bf 100644
--- a/packages/eve/test/tui-client/tui-traces.ts
+++ b/packages/eve/test/tui-client/tui-traces.ts
@@ -140,7 +140,7 @@ void (async () => {
end: 7_000,
parentSpanId: turn,
attributes: {
- "agent.action.call_id": "call-1",
+ "gen_ai.tool.call.id": "call-1",
"agent.action.kind": "subagent-call",
"agent.action.name": "echo",
"agent.turn.id": "turn_0",