Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

feat(eve): emit traces by default (#2643)

Chad Hietala8bdf67fbb6f5
diff --git a/.changeset/trace-policy-capture-decisions.md b/.changeset/trace-policy-capture-decisions.md
index 043fdbf68..d5ae472e0 100644
--- a/.changeset/trace-policy-capture-decisions.md
+++ b/.changeset/trace-policy-capture-decisions.md
@@ -2,4 +2,4 @@
"eve": minor
---
-Allow `tracePolicy` to explicitly disable emission or select directional content capture while preserving existing boolean policies, lifecycle delivery, and per-delivery audience ceilings.
+Emit traces for every audience by default while recording content only for public conversations. `tracePolicy` can explicitly disable emission or select directional content capture, and existing boolean policies retain their current behavior.
diff --git a/packages/eve/src/harness/tool-loop.test.ts b/packages/eve/src/harness/tool-loop.test.ts
index e3e5393d0..0ebead9f8 100644
--- a/packages/eve/src/harness/tool-loop.test.ts
+++ b/packages/eve/src/harness/tool-loop.test.ts
@@ -11295,7 +11295,7 @@ describe("createToolLoopHarness", () => {
});
});
- it("does not emit hosted unknown model telemetry", async () => {
+ it("emits hosted unknown model telemetry without content", async () => {
setupMockAgent({
finishReason: "stop",
response: { messages: [{ content: "Hello!", role: "assistant" }] },
@@ -11311,7 +11311,10 @@ describe("createToolLoopHarness", () => {
const agentCall = vi.mocked(ToolLoopAgent).mock.calls[0]?.[0] as {
telemetry?: { recordInputs?: boolean; recordOutputs?: boolean };
};
- expect(agentCall.telemetry).toBeUndefined();
+ expect(agentCall.telemetry).toMatchObject({
+ recordInputs: false,
+ recordOutputs: false,
+ });
});
it("keeps unknown model telemetry content in a local development worker", async () => {
diff --git a/packages/eve/src/tracing/agent-otel-provider.test.ts b/packages/eve/src/tracing/agent-otel-provider.test.ts
index 0cfda9589..4adae02eb 100644
--- a/packages/eve/src/tracing/agent-otel-provider.test.ts
+++ b/packages/eve/src/tracing/agent-otel-provider.test.ts
@@ -800,7 +800,7 @@ describe("createAgentOtelInstrumentation", () => {
});
it.each(["private", "unknown"] as const)(
- "does not record %s conversation traces by default",
+ "records %s conversation traces by default",
async (audience) => {
const runtime = createRuntime(new InMemoryAgentTraceStateStore(), null);
@@ -814,6 +814,28 @@ describe("createAgentOtelInstrumentation", () => {
});
await runtime.provider.forceFlush();
+ expect(byName(runtime.exporter.getFinishedSpans(), "agent.session")).toHaveLength(1);
+ },
+ );
+
+ it.each([
+ ["legacy false", (): boolean => false],
+ ["explicit emit false", (): { readonly emit: false } => ({ emit: false })],
+ ] as const)(
+ "does not emit a trace when the policy overrides the default with %s",
+ async (_name, tracePolicy) => {
+ const runtime = createRuntime(new InMemoryAgentTraceStateStore(), tracePolicy);
+
+ await emitAttempt({
+ channelAudience: "public",
+ hooks: runtime.hooks,
+ runInContext: runtime.runInContext,
+ sessionId: "session-rejected",
+ turnId: "turn-rejected",
+ turnSequence: 0,
+ });
+ await runtime.provider.forceFlush();
+
expect(runtime.exporter.getFinishedSpans()).toEqual([]);
},
);
diff --git a/packages/eve/src/tracing/otel-declaration.ts b/packages/eve/src/tracing/otel-declaration.ts
index f2effad03..f8145138e 100644
--- a/packages/eve/src/tracing/otel-declaration.ts
+++ b/packages/eve/src/tracing/otel-declaration.ts
@@ -62,8 +62,8 @@ export interface OtelOptions {
/**
* Process-wide trace and content decision. Boolean returns preserve the
* existing audience-aware behavior; explicit decisions can disable emission
- * or select input and output capture independently. Defaults to retaining
- * public conversations with content. The result is a capture ceiling:
+ * or select input and output capture independently. Defaults to emitting
+ * every audience, with content only for public conversations. The result is a capture ceiling:
* per-delivery audience and destination settings can only narrow it. A thrown
* error rejects trace production without silencing lifecycle providers.
*/
diff --git a/packages/eve/src/tracing/sampled-trace.test.ts b/packages/eve/src/tracing/sampled-trace.test.ts
index 3b59b5c26..f95533143 100644
--- a/packages/eve/src/tracing/sampled-trace.test.ts
+++ b/packages/eve/src/tracing/sampled-trace.test.ts
@@ -62,4 +62,16 @@ describe("resolveTracePolicyDecision", () => {
),
).toEqual({ action: "drop" });
});
+
+ it.each([
+ ["public", true],
+ ["private", false],
+ ["unknown", false],
+ ] as const)("emits the default %s trace with the expected content", (audience, content) => {
+ expect(resolveTracePolicy(undefined, { audience })).toEqual({
+ action: "record",
+ recordInputs: content,
+ recordOutputs: content,
+ });
+ });
});
diff --git a/packages/eve/src/tracing/sampled-trace.ts b/packages/eve/src/tracing/sampled-trace.ts
index 547b74d6e..fb087bc25 100644
--- a/packages/eve/src/tracing/sampled-trace.ts
+++ b/packages/eve/src/tracing/sampled-trace.ts
@@ -34,12 +34,17 @@ export function resolveTracePolicy(
},
): InstrumentationDecision {
try {
+ const decision = policy?.({
+ agentName: trace.agentName,
+ audience: trace.audience,
+ channelType: trace.channelType,
+ });
return resolveTracePolicyDecision(
- policy?.({
- agentName: trace.agentName,
- audience: trace.audience,
- channelType: trace.channelType,
- }) ?? trace.audience === "public",
+ decision ?? {
+ emit: true,
+ recordInputs: trace.audience === "public",
+ recordOutputs: trace.audience === "public",
+ },
trace.audience,
);
} catch {
diff --git a/research/channel-audience-content-policy.md b/research/channel-audience-content-policy.md
index d7336a92e..d814e8f2a 100644
--- a/research/channel-audience-content-policy.md
+++ b/research/channel-audience-content-policy.md
@@ -141,14 +141,18 @@ export default agentRuns({
The default authored and production head policy is equivalent to:
```ts
-({ audience }) => audience === "public";
+({ audience }) => ({
+ emit: true,
+ recordInputs: audience === "public",
+ recordOutputs: audience === "public",
+});
```
| Audience | Trace created by default | Content when admitted by a custom trace policy |
| --------- | ------------------------ | ---------------------------------------------- |
-| `public` | Yes | Unchanged unless an export policy redacts it |
-| `private` | No | Unchanged unless an export policy redacts it |
-| `unknown` | No | Unchanged unless an export policy redacts it |
+| `public` | Yes | Yes |
+| `private` | Yes | No |
+| `unknown` | Yes | No |
The default policy for local tracing for `eve dev` is equivalent to: