Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): protect non-public observability content (#2392)

Chad Hietala85b2dc8bde7a
diff --git a/.changeset/hosted-audience-content-privacy.md b/.changeset/hosted-audience-content-privacy.md
new file mode 100644
index 000000000..43df337fa
--- /dev/null
+++ b/.changeset/hosted-audience-content-privacy.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Redact model, tool, approval, and delivery content from hosted instrumentation for private and unknown channel audiences. Content-denied Workflow runs now carry a metadata marker and omit their content-derived title so dashboards can exclude them without reading the event stream. Local `eve dev` tracing continues to retain content for unknown TUI and HTTP sessions.
diff --git a/packages/eve/src/channel/subagent-emitter.test.ts b/packages/eve/src/channel/subagent-emitter.test.ts
index 688d2d51d..5a4ef7063 100644
--- a/packages/eve/src/channel/subagent-emitter.test.ts
+++ b/packages/eve/src/channel/subagent-emitter.test.ts
@@ -34,6 +34,7 @@ describe("subagent adapter", () => {
parentSessionId: "parent-session",
subagentName: "summarizer",
},
+ audience: "unknown",
});
const rehydrated = deserializeRuntimeAdapter(
diff --git a/packages/eve/src/execution/dispatch-turn-step.ts b/packages/eve/src/execution/dispatch-turn-step.ts
index 1cd87aeed..9297d2adc 100644
--- a/packages/eve/src/execution/dispatch-turn-step.ts
+++ b/packages/eve/src/execution/dispatch-turn-step.ts
@@ -22,6 +22,7 @@ export async function dispatchTurnStep(
parentSessionId: input.sessionState.sessionId,
requestId: input.delivery.kind === "deliver" ? input.delivery.requestId : undefined,
rootSessionId: readRootSessionId(input.serializedContext) ?? input.sessionState.sessionId,
+ serializedContext: input.serializedContext,
}),
),
},
diff --git a/packages/eve/src/execution/eve-workflow-attributes.test.ts b/packages/eve/src/execution/eve-workflow-attributes.test.ts
index 4a91b4d49..be8b0bec1 100644
--- a/packages/eve/src/execution/eve-workflow-attributes.test.ts
+++ b/packages/eve/src/execution/eve-workflow-attributes.test.ts
@@ -1,4 +1,4 @@
-import { describe, expect, it } from "vitest";
+import { afterEach, describe, expect, it, vi } from "vitest";
import {
buildSessionAttributes,
@@ -15,11 +15,11 @@ import {
import { ChannelRequestIdKey } from "#context/keys.js";
const slackChannelCtx = {
- "eve.channel": { kind: "slack", state: { team: "T1" } },
+ "eve.channel": { kind: "slack", state: { team: "T1" }, audience: "public" },
} satisfies Record<string, unknown>;
const subagentChainCtx = {
- "eve.channel": { kind: "slack", state: {} },
+ "eve.channel": { kind: "slack", state: {}, audience: "public" },
"eve.parentSession": {
callId: "call_subagent_0",
sessionId: "wrun_parent_subagent",
@@ -28,6 +28,10 @@ const subagentChainCtx = {
},
} satisfies Record<string, unknown>;
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
+
describe("readChannelKind", () => {
it("returns the channel kind when the slot is well-formed", () => {
expect(readChannelKind(slackChannelCtx)).toBe("slack");
@@ -146,20 +150,34 @@ describe("buildSessionAttributes", () => {
expect(attrs).toEqual({
"$eve.channel_request_id": undefined,
+ "$eve.is_trace_content_visible": true,
"$eve.type": "session",
"$eve.trigger": "slack",
"$eve.title": "ship the thing please",
});
});
- it("omits the trigger when no channel is on the context", () => {
+ it("marks unknown sessions denied and omits their content-derived title", () => {
const attrs = buildSessionAttributes({
inputMessage: "hi",
serializedContext: {},
});
expect(attrs["$eve.trigger"]).toBeUndefined();
- expect(attrs["$eve.title"]).toBe("hi");
+ expect(attrs["$eve.is_trace_content_visible"]).toBe(false);
+ expect(attrs["$eve.title"]).toBeUndefined();
+ });
+
+ it("allows unknown session content during local eve dev", () => {
+ vi.stubEnv("EVE_DEV", "1");
+
+ const attrs = buildSessionAttributes({
+ inputMessage: "local prompt",
+ serializedContext: {},
+ });
+
+ expect(attrs["$eve.is_trace_content_visible"]).toBe(true);
+ expect(attrs["$eve.title"]).toBe("local prompt");
});
it("emits the channel request id when present", () => {
@@ -188,6 +206,7 @@ describe("buildSubagentRootAttributes", () => {
expect(attrs).toEqual({
"$eve.channel_request_id": undefined,
+ "$eve.is_trace_content_visible": true,
"$eve.type": "subagent",
"$eve.parent": "wrun_parent_subagent",
"$eve.parent_call": "call_subagent_0",
@@ -218,10 +237,12 @@ describe("buildTurnAttributes", () => {
const attrs = buildTurnAttributes({
parentSessionId: "wrun_session_123",
rootSessionId: "wrun_session_123",
+ serializedContext: slackChannelCtx,
});
expect(attrs).toEqual({
"$eve.channel_request_id": undefined,
+ "$eve.is_trace_content_visible": true,
"$eve.type": "turn",
"$eve.parent": "wrun_session_123",
"$eve.root": "wrun_session_123",
@@ -233,6 +254,7 @@ describe("buildTurnAttributes", () => {
parentSessionId: "wrun_session_123",
requestId: "req_turn",
rootSessionId: "wrun_session_123",
+ serializedContext: slackChannelCtx,
});
expect(attrs["$eve.channel_request_id"]).toBe("req_turn");
diff --git a/packages/eve/src/execution/eve-workflow-attributes.ts b/packages/eve/src/execution/eve-workflow-attributes.ts
index 826719c9c..396bc370e 100644
--- a/packages/eve/src/execution/eve-workflow-attributes.ts
+++ b/packages/eve/src/execution/eve-workflow-attributes.ts
@@ -25,10 +25,13 @@
* - `$eve.channel_request_id` — inbound channel request id
* - `$eve.invocation_token` — channel-local continuation token for an external invocation
* - `$eve.invocation_owner` — SHA-256 fingerprint of the invocation's initiating principal
+ * - `$eve.is_trace_content_visible` — whether observability may read content-bearing workflow data
*/
import { ChannelRequestIdKey } from "#context/keys.js";
+import { shouldCaptureInstrumentationContent } from "#harness/instrumentation/content-policy.js";
import type { EveAttributeValue } from "#runtime/attributes/normalize.js";
+import { normalizeChannelAudience } from "#shared/channel-audience.js";
import { isNonEmptyString } from "#shared/guards.js";
/**
@@ -46,6 +49,7 @@ export interface SessionIdentitySummary {
/** Untyped channel adapter snapshot as it survives serialization. */
interface SerializedChannelAdapter {
readonly kind?: unknown;
+ readonly audience?: unknown;
}
/** Untyped session parent snapshot as it survives serialization. */
@@ -79,6 +83,11 @@ export function readChannelKind(serializedContext: Record<string, unknown>): str
return isNonEmptyString(kind) ? kind : undefined;
}
+export function isWorkflowTraceContentVisible(serializedContext: Record<string, unknown>): boolean {
+ const channel = serializedContext["eve.channel"] as SerializedChannelAdapter | undefined;
+ return shouldCaptureInstrumentationContent(normalizeChannelAudience(channel?.audience));
+}
+
/**
* Reads parent session lineage from a deserialized context map. Returns
* an empty object for top-level runs or malformed delegated contexts.
@@ -209,11 +218,13 @@ export function buildSessionAttributes(input: {
readonly inputMessage: unknown;
readonly serializedContext: Record<string, unknown>;
}): Record<string, EveAttributeValue> {
+ const isTraceContentVisible = isWorkflowTraceContentVisible(input.serializedContext);
return {
"$eve.channel_request_id": readChannelRequestId(input.serializedContext),
+ "$eve.is_trace_content_visible": isTraceContentVisible,
"$eve.type": "session",
"$eve.trigger": readChannelKind(input.serializedContext),
- "$eve.title": deriveSessionTitle(input.inputMessage),
+ "$eve.title": isTraceContentVisible ? deriveSessionTitle(input.inputMessage) : undefined,
};
}
@@ -236,6 +247,7 @@ export function buildSubagentRootAttributes(input: {
}): Record<string, EveAttributeValue> {
return {
"$eve.channel_request_id": readChannelRequestId(input.serializedContext),
+ "$eve.is_trace_content_visible": isWorkflowTraceContentVisible(input.serializedContext),
"$eve.type": "subagent",
"$eve.parent": input.parentSessionId,
"$eve.parent_call": input.parentCallId,
@@ -260,9 +272,11 @@ export function buildTurnAttributes(input: {
readonly parentSessionId: string;
readonly requestId?: string;
readonly rootSessionId: string;
+ readonly serializedContext: Record<string, unknown>;
}): Record<string, EveAttributeValue> {
return {
"$eve.channel_request_id": input.requestId,
+ "$eve.is_trace_content_visible": isWorkflowTraceContentVisible(input.serializedContext),
"$eve.type": "turn",
"$eve.parent": input.parentSessionId,
"$eve.root": input.rootSessionId,
diff --git a/packages/eve/src/execution/subagent-auth-proxy.integration.test.ts b/packages/eve/src/execution/subagent-auth-proxy.integration.test.ts
index 6b5b59c3d..feabd560c 100644
--- a/packages/eve/src/execution/subagent-auth-proxy.integration.test.ts
+++ b/packages/eve/src/execution/subagent-auth-proxy.integration.test.ts
@@ -220,6 +220,7 @@ describe("subagent authorization proxy", () => {
expect(required.serializedContext[ChannelKey.name]).toEqual({
kind: authorizationAdapter.kind,
state: { pendingName: "linear" },
+ audience: "unknown",
});
const completedEvent: SubagentAuthorizationEvent = {
@@ -243,6 +244,7 @@ describe("subagent authorization proxy", () => {
expect(completed.serializedContext[ChannelKey.name]).toEqual({
kind: authorizationAdapter.kind,
state: { outcome: "authorized" },
+ audience: "unknown",
});
expect(chunks).toHaveLength(2);
expect(decodeEvent(chunks[0]!)).toMatchObject(requiredEvent);
diff --git a/packages/eve/src/execution/workflow-entry.integration.test.ts b/packages/eve/src/execution/workflow-entry.integration.test.ts
index 2263585f9..db8cee118 100644
--- a/packages/eve/src/execution/workflow-entry.integration.test.ts
+++ b/packages/eve/src/execution/workflow-entry.integration.test.ts
@@ -29,6 +29,7 @@ import type { ResolvedToolDefinition } from "#runtime/types.js";
import { toInputSchema } from "#shared/tool-schema.js";
function buildSerializedContext(overrides: {
+ audience?: "public" | "private" | "unknown";
auth?: Record<string, unknown>;
channelKind: string;
channelState?: Record<string, unknown>;
@@ -44,10 +45,17 @@ function buildSerializedContext(overrides: {
};
};
}): Record<string, unknown> {
+ const channel: { kind: unknown; state: unknown; audience?: unknown } = {
+ kind: overrides.channelKind,
+ state: overrides.channelState ?? {},
+ };
+ if (overrides.audience !== undefined) {
+ channel.audience = overrides.audience;
+ }
const context: Record<string, unknown> = {
"eve.auth": overrides.auth ?? null,
"eve.bundle": { source: createBundledRuntimeCompiledArtifactsSource() },
- "eve.channel": { kind: overrides.channelKind, state: overrides.channelState ?? {} },
+ "eve.channel": channel,
"eve.mode": overrides.mode,
};
if (overrides.continuationToken !== undefined) {
@@ -1140,6 +1148,7 @@ describe("workflowEntry integration", () => {
await runtime.run(async () => {
const serializedContext = buildSerializedContext({
+ audience: "public",
channelKind: "http",
continuationToken,
mode: "conversation",
@@ -1172,6 +1181,7 @@ describe("workflowEntry integration", () => {
const attrs = (persisted as { attributes?: Record<string, string> }).attributes ?? {};
expect(attrs["$eve.type"]).toBe("session");
+ expect(attrs["$eve.is_trace_content_visible"]).toBe("true");
expect(attrs["$eve.trigger"]).toBe("http");
expect(attrs["$eve.title"]).toContain("session tag round-trip");
// Top-level sessions have no parent or subagent name on the root run.
@@ -1189,6 +1199,7 @@ describe("workflowEntry integration", () => {
await runtime.run(async () => {
const serializedContext = buildSerializedContext({
+ audience: "public",
channelKind: "subagent",
continuationToken: "subagent:parent-session:call-subagent-1",
mode: "task",
@@ -1232,6 +1243,7 @@ describe("workflowEntry integration", () => {
const attrs = (persisted as { attributes?: Record<string, string> }).attributes ?? {};
expect(attrs["$eve.type"]).toBe("subagent");
+ expect(attrs["$eve.is_trace_content_visible"]).toBe("true");
expect(attrs["$eve.parent"]).toBe("parent-session");
expect(attrs["$eve.parent_call"]).toBe("call-subagent-1");
expect(attrs["$eve.parent_turn"]).toBe("turn-parent");
diff --git a/packages/eve/src/execution/workflow-runtime.test.ts b/packages/eve/src/execution/workflow-runtime.test.ts
index f2f857b6c..60e4c9ee2 100644
--- a/packages/eve/src/execution/workflow-runtime.test.ts
+++ b/packages/eve/src/execution/workflow-runtime.test.ts
@@ -377,7 +377,7 @@ describe("createWorkflowRuntime#createSession", () => {
input: { message: "hello" },
serializedContext: expect.objectContaining({
"eve.bundle": { source: compiledArtifactsSource },
- "eve.channel": { kind: "http", state: {} },
+ "eve.channel": expect.objectContaining({ kind: "http", state: {} }),
"eve.mode": "task",
}),
},
@@ -385,7 +385,7 @@ describe("createWorkflowRuntime#createSession", () => {
{
allowReservedAttributes: true,
attributes: {
- "$eve.title": "hello",
+ "$eve.is_trace_content_visible": "false",
"$eve.trigger": "http",
"$eve.type": "session",
},
@@ -394,7 +394,7 @@ describe("createWorkflowRuntime#createSession", () => {
);
});
- it("uses an explicit title without changing the workflow model input", async () => {
+ it("withholds an explicit title for an unknown-audience workflow", async () => {
const compiledArtifactsSource = {} as RuntimeCompiledArtifactsSource;
mockBundleAndRun(compiledArtifactsSource);
startMock.mockResolvedValue({ runId: "driver-run" });
@@ -410,7 +410,8 @@ describe("createWorkflowRuntime#createSession", () => {
const [, workflowInput, startOptions] = startMock.mock.calls[0]!;
expect(workflowInput[0].input.message).toBe(message);
- expect(startOptions.attributes["$eve.title"]).toBe("ship it");
+ expect(startOptions.attributes["$eve.is_trace_content_visible"]).toBe("false");
+ expect(startOptions.attributes["$eve.title"]).toBeUndefined();
});
it("passes the configured session timeout to the durable workflow", async () => {
@@ -493,7 +494,7 @@ describe("createWorkflowRuntime#createSession", () => {
allowReservedAttributes: true,
attributes: {
"$eve.channel_request_id": "req_run",
- "$eve.title": "hello",
+ "$eve.is_trace_content_visible": "false",
"$eve.trigger": "http",
"$eve.type": "session",
},
@@ -538,6 +539,7 @@ describe("createWorkflowRuntime#createSession", () => {
"$eve.parent_turn": "turn-1",
"$eve.root": "root-session",
"$eve.subagent": "researcher",
+ "$eve.is_trace_content_visible": "false",
"$eve.trigger": "subagent",
"$eve.type": "subagent",
},
@@ -562,7 +564,7 @@ describe("createWorkflowRuntime#createSession", () => {
expect(startMock).toHaveBeenNthCalledWith(1, workflowEntryReference, expect.any(Array), {
allowReservedAttributes: true,
attributes: {
- "$eve.title": "hello",
+ "$eve.is_trace_content_visible": "false",
"$eve.trigger": "http",
"$eve.type": "session",
},
@@ -571,7 +573,7 @@ describe("createWorkflowRuntime#createSession", () => {
expect(startMock).toHaveBeenNthCalledWith(2, workflowEntryReference, expect.any(Array), {
allowReservedAttributes: true,
attributes: {
- "$eve.title": "hello",
+ "$eve.is_trace_content_visible": "false",
"$eve.trigger": "http",
"$eve.type": "session",
},
@@ -605,7 +607,7 @@ describe("createWorkflowRuntime#createSession", () => {
expect(startMock).toHaveBeenCalledWith(workflowEntryReference, expect.any(Array), {
allowReservedAttributes: true,
attributes: {
- "$eve.title": "hello",
+ "$eve.is_trace_content_visible": "false",
"$eve.trigger": "http",
"$eve.type": "session",
},
diff --git a/packages/eve/src/execution/workflow-steps.test.ts b/packages/eve/src/execution/workflow-steps.test.ts
index e7a65c160..e516e9ee6 100644
--- a/packages/eve/src/execution/workflow-steps.test.ts
+++ b/packages/eve/src/execution/workflow-steps.test.ts
@@ -681,6 +681,7 @@ describe("dispatchTurnStep", () => {
"$eve.channel_request_id": "req_turn",
"$eve.parent": "sess-test",
"$eve.root": "sess-test",
+ "$eve.is_trace_content_visible": "false",
"$eve.type": "turn",
},
deploymentId: "latest",
@@ -719,6 +720,7 @@ describe("dispatchTurnStep", () => {
"$eve.channel_request_id": "req_turn",
"$eve.parent": "sess-test",
"$eve.root": "sess-test",
+ "$eve.is_trace_content_visible": "false",
"$eve.type": "turn",
},
},
@@ -741,6 +743,7 @@ describe("dispatchTurnStep", () => {
"$eve.channel_request_id": "req_turn",
"$eve.parent": "sess-test",
"$eve.root": "sess-test",
+ "$eve.is_trace_content_visible": "false",
"$eve.type": "turn",
},
deploymentId: "latest",
@@ -751,6 +754,7 @@ describe("dispatchTurnStep", () => {
"$eve.channel_request_id": "req_turn",
"$eve.parent": "sess-test",
"$eve.root": "sess-test",
+ "$eve.is_trace_content_visible": "false",
"$eve.type": "turn",
},
});
diff --git a/packages/eve/src/harness/channel-delivery-instrumentation.test.ts b/packages/eve/src/harness/channel-delivery-instrumentation.test.ts
index 576b87d4f..b26da50fe 100644
--- a/packages/eve/src/harness/channel-delivery-instrumentation.test.ts
+++ b/packages/eve/src/harness/channel-delivery-instrumentation.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import { ContextContainer, contextStorage } from "#context/container.js";
-import { ParentTraceContextKey } from "#context/keys.js";
+import { ChannelInstrumentationKey, ParentTraceContextKey } from "#context/keys.js";
import { instrumentChannelDelivery } from "#harness/channel-delivery-instrumentation.js";
import {
createInstrumentationHooks,
@@ -38,6 +38,10 @@ describe("channel delivery instrumentation", () => {
traceFlags: 1,
traceId: "11111111111111111111111111111111",
};
+ ctx.set(ChannelInstrumentationKey, {
+ kind: "channel:slack",
+ metadata: { audience: "public" },
+ });
ctx.set(ParentTraceContextKey, parentTraceContext);
await contextStorage.run(ctx, async () => {
diff --git a/packages/eve/src/harness/channel-delivery-instrumentation.ts b/packages/eve/src/harness/channel-delivery-instrumentation.ts
index dabfe29f6..0b640b02b 100644
--- a/packages/eve/src/harness/channel-delivery-instrumentation.ts
+++ b/packages/eve/src/harness/channel-delivery-instrumentation.ts
@@ -12,6 +12,7 @@ import type {
InstrumentationHooks,
} from "#harness/instrumentation/lifecycle.js";
import { channelDeliveryIdempotencyKey } from "#harness/instrumentation/lifecycle.js";
+import { instrumentationHooksForAudience } from "#harness/instrumentation/content-policy.js";
import { normalizeChannelAudience } from "#shared/channel-audience.js";
interface ChannelDeliveryStartInstrumentation {
@@ -49,7 +50,11 @@ export async function instrumentChannelDelivery(
const type =
`channel.delivery.${input.outcome}` as InstrumentationChannelDeliveryTerminalEvent["type"];
for (const item of active) {
- await input.hooks.publish({
+ const hooks = instrumentationHooksForAudience(
+ input.hooks,
+ normalizeChannelAudience(item.delivery.channelAudience),
+ );
+ await hooks?.publish({
agentName: item.agentName,
delivery: item.delivery,
error: input.error,
@@ -73,6 +78,7 @@ export async function instrumentChannelDelivery(
const channelAudience = normalizeChannelAudience(
input.ctx.get(ChannelInstrumentationKey)?.metadata.audience,
);
+ const hooks = instrumentationHooksForAudience(input.hooks, channelAudience);
for (const metadata of input.delivery.deliveryMetadata) {
const payload = input.delivery.payloads[metadata.payloadIndex];
const delivery = {
@@ -84,9 +90,7 @@ export async function instrumentChannelDelivery(
requestTraceContext: metadata.requestTraceContext,
};
const deliveryInput =
- !input.hooks.capturesContent || payload === undefined
- ? undefined
- : projectDeliveryInput(payload);
+ !hooks?.capturesContent || payload === undefined ? undefined : projectDeliveryInput(payload);
const item: ActiveChannelDelivery = {
agentName: input.agentName,
delivery,
@@ -96,7 +100,7 @@ export async function instrumentChannelDelivery(
turnId: input.turnId,
};
active.push(item);
- await input.hooks.publish({
+ await hooks?.publish({
agentName: item.agentName,
delivery,
idempotencyKey: channelDeliveryIdempotencyKey(input.sessionId, delivery.deliveryId),
diff --git a/packages/eve/src/harness/instrumentation/content-policy.test.ts b/packages/eve/src/harness/instrumentation/content-policy.test.ts
new file mode 100644
index 000000000..5275093a0
--- /dev/null
+++ b/packages/eve/src/harness/instrumentation/content-policy.test.ts
@@ -0,0 +1,52 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import {
+ instrumentationHooksForAudience,
+ shouldCaptureInstrumentationContent,
+} from "#harness/instrumentation/content-policy.js";
+import type { InstrumentationHooks } from "#harness/instrumentation/lifecycle.js";
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
+
+describe("instrumentation content policy", () => {
+ it("captures only public content in hosted workers", () => {
+ expect(shouldCaptureInstrumentationContent("public")).toBe(true);
+ expect(shouldCaptureInstrumentationContent("private")).toBe(false);
+ expect(shouldCaptureInstrumentationContent("unknown")).toBe(false);
+ });
+
+ it("keeps the local unknown-audience exception without admitting private content", () => {
+ vi.stubEnv("EVE_DEV", "1");
+
+ expect(shouldCaptureInstrumentationContent("public")).toBe(true);
+ expect(shouldCaptureInstrumentationContent("private")).toBe(false);
+ expect(shouldCaptureInstrumentationContent("unknown")).toBe(true);
+ });
+
+ it("strips content before publishing to hosted providers", async () => {
+ const publish = vi.fn();
+ const hooks: InstrumentationHooks = { capturesContent: true, publish };
+ const restricted = instrumentationHooksForAudience(hooks, "private");
+
+ await restricted?.publish({
+ callId: "call-1",
+ idempotencyKey: "action-1",
+ input: { secret: "value" },
+ kind: "tool-call",
+ name: "lookup",
+ scope: {
+ attemptId: "attempt-1",
+ attemptIndex: 0,
+ sessionId: "session-1",
+ stepIndex: 0,
+ turnId: "turn-1",
+ },
+ type: "action.started",
+ });
+
+ expect(restricted?.capturesContent).toBe(false);
+ expect(publish).toHaveBeenCalledWith(expect.objectContaining({ input: undefined }));
+ });
+});
diff --git a/packages/eve/src/harness/instrumentation/content-policy.ts b/packages/eve/src/harness/instrumentation/content-policy.ts
new file mode 100644
index 000000000..be9c3f988
--- /dev/null
+++ b/packages/eve/src/harness/instrumentation/content-policy.ts
@@ -0,0 +1,29 @@
+import type { InstrumentationHooks } from "#harness/instrumentation/lifecycle.js";
+import { withoutInstrumentationContent } from "#harness/instrumentation/content.js";
+import { isEveDevEnvironment } from "#internal/application/dev-environment.js";
+import type { ChannelAudience } from "#shared/channel-audience.js";
+
+/** Hosted instrumentation records conversation content only for known-public channels. */
+export function shouldCaptureInstrumentationContent(audience: ChannelAudience): boolean {
+ if (audience === "public") return true;
+ return audience === "unknown" && isEveDevEnvironment();
+}
+
+/** Applies the audience ceiling before any content-capable provider sees an event. */
+export function instrumentationHooksForAudience(
+ hooks: InstrumentationHooks | undefined,
+ audience: ChannelAudience,
+): InstrumentationHooks | undefined {
+ if (
+ hooks === undefined ||
+ !hooks.capturesContent ||
+ shouldCaptureInstrumentationContent(audience)
+ ) {
+ return hooks;
+ }
+
+ return {
+ capturesContent: false,
+ publish: (event) => hooks.publish(withoutInstrumentationContent(event)),
+ };
+}
diff --git a/packages/eve/src/harness/instrumentation/lifecycle.ts b/packages/eve/src/harness/instrumentation/lifecycle.ts
index 9598608c0..b09629d91 100644
--- a/packages/eve/src/harness/instrumentation/lifecycle.ts
+++ b/packages/eve/src/harness/instrumentation/lifecycle.ts
@@ -113,6 +113,8 @@ export type InstrumentationActionOutput =
* some provider asked for it, and a provider that did not ask never receives
* it — which is the same guarantee a destination that declines content gets,
* one layer lower and without an OpenTelemetry pipeline to route it through.
+ * Runtime audience policy can still lower hosted private or unknown events to
+ * metadata before this provider-level projection.
*/
export type InstrumentationCapture = "content" | "metadata";
diff --git a/packages/eve/src/harness/instrumentation/runtime-context.test.ts b/packages/eve/src/harness/instrumentation/runtime-context.test.ts
index ed48f80db..c7547830a 100644
--- a/packages/eve/src/harness/instrumentation/runtime-context.test.ts
+++ b/packages/eve/src/harness/instrumentation/runtime-context.test.ts
@@ -194,6 +194,47 @@ describe("buildTelemetryRuntimeContext", () => {
});
});
+ it("withholds model content from hosted unknown-audience resolvers", () => {
+ let captured: InstrumentationStepStartedEventInput | undefined;
+
+ build({
+ authored: {
+ events: {
+ "step.started": (input: InstrumentationStepStartedEventInput) => {
+ captured = input;
+ return { runtimeContext: {} };
+ },
+ },
+ },
+ });
+
+ expect(captured?.modelInput).toEqual({ instructions: undefined, messages: [] });
+ });
+
+ it("exposes model content to public-audience resolvers", () => {
+ const ctx = new ContextContainer();
+ ctx.set(ChannelInstrumentationKey, {
+ kind: "channel:public",
+ metadata: { audience: "public" },
+ });
+ let captured: InstrumentationStepStartedEventInput | undefined;
+
+ contextStorage.run(ctx, () =>
+ build({
+ authored: {
+ events: {
+ "step.started": (input: InstrumentationStepStartedEventInput) => {
+ captured = input;
+ return { runtimeContext: {} };
+ },
+ },
+ },
+ }),
+ );
+
+ expect(captured?.modelInput.messages).toEqual(messages);
+ });
+
it("snapshots resolver input so mutating live context cannot change it", () => {
const roles = ["admin"];
const channelMetadata = { nested: { value: "original" }, triggeringUserId: "U999" };
diff --git a/packages/eve/src/harness/instrumentation/runtime-context.ts b/packages/eve/src/harness/instrumentation/runtime-context.ts
index 64887d651..7bb16d59e 100644
--- a/packages/eve/src/harness/instrumentation/runtime-context.ts
+++ b/packages/eve/src/harness/instrumentation/runtime-context.ts
@@ -12,6 +12,7 @@ import {
import type { HarnessEmissionState } from "#harness/emission.js";
import type { HarnessSession } from "#harness/types.js";
import type { RuntimeContextResolver } from "#tracing/otel-declaration.js";
+import { shouldCaptureInstrumentationContent } from "#harness/instrumentation/content-policy.js";
import {
normalizeInstrumentationChannelKind,
resolveInstrumentationProjection,
@@ -23,6 +24,7 @@ import type {
InstrumentationRuntimeContext,
InstrumentationStepStartedEventInput,
} from "#public/instrumentation/index.js";
+import { normalizeChannelAudience } from "#shared/channel-audience.js";
import { parseJsonObject, parseJsonValue, type JsonObject, type JsonValue } from "#shared/json.js";
const log = createLogger("harness.instrumentation-runtime-context");
@@ -80,16 +82,21 @@ function buildInstrumentationStepStartedInput(
): InstrumentationStepStartedEventInput {
const context = contextStorage.getStore();
const projection = context?.get(ChannelInstrumentationKey);
+ const capturesContent = shouldCaptureInstrumentationContent(
+ normalizeChannelAudience(projection?.metadata.audience),
+ );
return {
channel: {
kind: normalizeInstrumentationChannelKind(projection?.kind),
metadata: snapshotForInstrumentation(projection?.metadata, "channel.metadata") ?? {},
} as InstrumentationChannel,
- modelInput: snapshotForInstrumentation(input.modelInput, "modelInput") ?? {
- instructions: undefined,
- messages: [],
- },
+ modelInput: capturesContent
+ ? (snapshotForInstrumentation(input.modelInput, "modelInput") ?? {
+ instructions: undefined,
+ messages: [],
+ })
+ : { instructions: undefined, messages: [] },
session: {
auth: projectSessionAuth(context),
id: input.session.sessionId,
diff --git a/packages/eve/src/harness/tool-loop.test.ts b/packages/eve/src/harness/tool-loop.test.ts
index 0e171a9c0..9c7144a89 100644
--- a/packages/eve/src/harness/tool-loop.test.ts
+++ b/packages/eve/src/harness/tool-loop.test.ts
@@ -4922,7 +4922,12 @@ describe("createToolLoopHarness", () => {
const { emit, events } = createEventCollector();
const runStep = createToolLoopHarness({ ...config, handleEvent: emit });
- const result = await runStep(session, { message: "Hi" });
+ const ctx = new ContextContainer();
+ ctx.set(ChannelInstrumentationKey, {
+ kind: "channel:public",
+ metadata: { audience: "public" },
+ });
+ const result = await contextStorage.run(ctx, () => runStep(session, { message: "Hi" }));
// The second agent was constructed for the retry.
expect(constructedCalls.count()).toBe(2);
@@ -10787,7 +10792,12 @@ describe("createToolLoopHarness", () => {
}),
);
- await runStep(createTestSession(), { message: "hi" });
+ const ctx = new ContextContainer();
+ ctx.set(ChannelInstrumentationKey, {
+ kind: "channel:public",
+ metadata: { audience: "public" },
+ });
+ await contextStorage.run(ctx, () => runStep(createTestSession(), { message: "hi" }));
const bridge = mockCreateAiSdkHookBridge.mock.results[0]!.value;
const agentCall = vi.mocked(ToolLoopAgent).mock.calls[0]?.[0] as {
@@ -10804,6 +10814,51 @@ describe("createToolLoopHarness", () => {
});
});
+ it("forces hosted unknown model telemetry to metadata only", async () => {
+ setupMockAgent({
+ finishReason: "stop",
+ response: { messages: [{ content: "Hello!", role: "assistant" }] },
+ text: "Hello!",
+ toolCalls: [],
+ toolResults: [],
+ });
+ declareTelemetry({ recordInputs: true, recordOutputs: true });
+
+ const runStep = createToolLoopHarness(createTestConfig("conversation"));
+ await runStep(createTestSession(), { message: "hi" });
+
+ const agentCall = vi.mocked(ToolLoopAgent).mock.calls[0]?.[0] as {
+ telemetry?: { recordInputs?: boolean; recordOutputs?: boolean };
+ };
+ expect(agentCall.telemetry).toMatchObject({
+ recordInputs: false,
+ recordOutputs: false,
+ });
+ });
+
+ it("keeps unknown model telemetry content in a local development worker", async () => {
+ vi.stubEnv("EVE_DEV", "1");
+ setupMockAgent({
+ finishReason: "stop",
+ response: { messages: [{ content: "Hello!", role: "assistant" }] },
+ text: "Hello!",
+ toolCalls: [],
+ toolResults: [],
+ });
+ declareTelemetry({ recordInputs: true, recordOutputs: true });
+
+ const runStep = createToolLoopHarness(createTestConfig("conversation"));
+ await runStep(createTestSession(), { message: "hi" });
+
+ const agentCall = vi.mocked(ToolLoopAgent).mock.calls[0]?.[0] as {
+ telemetry?: { recordInputs?: boolean; recordOutputs?: boolean };
+ };
+ expect(agentCall.telemetry).toMatchObject({
+ recordInputs: true,
+ recordOutputs: true,
+ });
+ });
+
it("merges step-started runtime context before emitting step.started", async () => {
setupMockAgent({
finishReason: "stop",
@@ -10845,6 +10900,7 @@ describe("createToolLoopHarness", () => {
ctx.set(ChannelInstrumentationKey, {
kind: "channel:support",
metadata: {
+ audience: "public",
triggeringUserId: "U123",
},
});
diff --git a/packages/eve/src/harness/tool-loop.ts b/packages/eve/src/harness/tool-loop.ts
index 5a1e77d5d..a338ee47a 100644
--- a/packages/eve/src/harness/tool-loop.ts
+++ b/packages/eve/src/harness/tool-loop.ts
@@ -55,7 +55,7 @@ import {
import { buildDynamicSubagentTools } from "#context/dynamic-subagent-lifecycle.js";
import { PendingSkillAnnouncementKey } from "#context/dynamic-skill-lifecycle.js";
import { toErrorMessage } from "#shared/errors.js";
-import { normalizeChannelAudience } from "#shared/channel-audience.js";
+import { normalizeChannelAudience, type ChannelAudience } from "#shared/channel-audience.js";
import {
createActionResultEvent,
createApprovalCandidateEvent,
@@ -142,6 +142,10 @@ import {
shouldPrepareApprovalPolicyTools,
} from "#harness/approval-delivery-coordinator.js";
import { buildTelemetryRuntimeContext } from "#harness/instrumentation/runtime-context.js";
+import {
+ instrumentationHooksForAudience,
+ shouldCaptureInstrumentationContent,
+} from "#harness/instrumentation/content-policy.js";
import { createAiSdkHookBridge } from "#harness/ai-sdk-hook-bridge.js";
import {
createInstrumentationHandleEvent,
@@ -320,6 +324,7 @@ const MODEL_CALL_RETRY_BASE_DELAY_MS = 500;
function enrichTelemetry(
settings: OtelHarnessSettings | undefined,
+ channelAudience: ChannelAudience,
agentName: string | undefined,
runtimeContext?: Readonly<Record<string, unknown>>,
bridgeIntegration?: Telemetry,
@@ -345,8 +350,10 @@ function enrichTelemetry(
? undefined
: [bridgeIntegration, ...getRegisteredTelemetryIntegrations()],
isEnabled: true,
- recordInputs: settings?.recordInputs ?? false,
- recordOutputs: settings?.recordOutputs ?? false,
+ recordInputs:
+ shouldCaptureInstrumentationContent(channelAudience) && (settings?.recordInputs ?? false),
+ recordOutputs:
+ shouldCaptureInstrumentationContent(channelAudience) && (settings?.recordOutputs ?? false),
};
}
@@ -650,6 +657,11 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {
let emissionState = getHarnessEmissionState(session.state);
const store = contextStorage.getStore();
const channelInstrumentation = store?.get(ChannelInstrumentationKey);
+ const channelAudience = normalizeChannelAudience(channelInstrumentation?.metadata.audience);
+ const instrumentationHooks = instrumentationHooksForAudience(
+ config.instrumentation?.hooks,
+ channelAudience,
+ );
const parent = store?.get(ParentSessionKey);
const channel = store?.get(ChannelKey);
const callback = store?.get(SessionCallbackKey);
@@ -663,11 +675,11 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {
let activeAttemptScope: InstrumentationAttemptScope | undefined;
const emit = createInstrumentationHandleEvent({
agentName: config.runtimeIdentity?.agentName,
- channelAudience: normalizeChannelAudience(channelInstrumentation?.metadata.audience),
+ channelAudience,
channelKind: channelInstrumentation?.kind,
getAttemptScope: () => activeAttemptScope,
handleEvent: baseEmit,
- hooks: config.instrumentation?.hooks,
+ hooks: instrumentationHooks,
parentLineage,
parentTraceContext,
rootSessionId: parent?.rootSessionId,
@@ -721,7 +733,7 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {
: undefined;
return await prepareTurnTraceContext({
agentName: config.runtimeIdentity?.agentName,
- channelAudience: normalizeChannelAudience(channelInstrumentation?.metadata.audience),
+ channelAudience,
instrumentation: config.instrumentation,
parentLineage,
parentTraceContext,
@@ -776,7 +788,7 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {
resolveModel: config.resolveModel,
runtimeIdentity: config.runtimeIdentity,
session,
- telemetry: enrichTelemetry(otelSettings, agentName) ?? undefined,
+ telemetry: enrichTelemetry(otelSettings, channelAudience, agentName) ?? undefined,
});
session = {
@@ -1066,10 +1078,10 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {
if (pending.resolvedInputs !== undefined) {
for (const batch of pending.resolvedInputs) {
- if (config.instrumentation?.hooks !== undefined) {
+ if (instrumentationHooks !== undefined) {
await publishInputResolutions({
batch,
- hooks: config.instrumentation.hooks,
+ hooks: instrumentationHooks,
sessionId: session.sessionId,
});
}
@@ -1270,7 +1282,7 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {
resolveModel: config.resolveModel,
runtimeIdentity: config.runtimeIdentity,
session,
- telemetry: enrichTelemetry(otelSettings, agentName) ?? undefined,
+ telemetry: enrichTelemetry(otelSettings, channelAudience, agentName) ?? undefined,
});
session = compaction.session;
if (compaction.compacted) {
@@ -1493,7 +1505,6 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {
const effectiveTools = marker ? applyLastToolCacheBreakpoint(modelTools, marker) : modelTools;
- const instrumentationHooks = config.instrumentation?.hooks;
const instrumentationTurnId = activeTurnId(emissionState);
const attemptScope: InstrumentationAttemptScope | undefined =
instrumentationHooks === undefined
@@ -1501,7 +1512,7 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {
: {
attemptId: `${session.sessionId}:${instrumentationTurnId}:${emissionState.stepIndex}:${opts.attemptIndex}`,
attemptIndex: opts.attemptIndex,
- channelAudience: normalizeChannelAudience(channelInstrumentation?.metadata.audience),
+ channelAudience,
functionId: otelSettings?.functionId ?? agentName,
rootSessionId: parent?.rootSessionId ?? session.sessionId,
sessionId: session.sessionId,
@@ -1567,6 +1578,7 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {
stopWhen: isStepCount(1),
telemetry: enrichTelemetry(
otelSettings,
+ channelAudience,
agentName,
telemetryRuntimeContext,
bridgeIntegration,
diff --git a/packages/eve/src/runtime/attributes/emit.test.ts b/packages/eve/src/runtime/attributes/emit.test.ts
index f6c04b5fc..724d6b292 100644
--- a/packages/eve/src/runtime/attributes/emit.test.ts
+++ b/packages/eve/src/runtime/attributes/emit.test.ts
@@ -61,6 +61,16 @@ describe("setEveAttributes", () => {
);
});
+ it('stringifies boolean attribute values as "true"/"false"', async () => {
+ await setEveAttributes({ "$eve.is_trace_content_visible": true, "$eve.flag": false });
+
+ expect(setAttributesMock).toHaveBeenCalledTimes(1);
+ expect(setAttributesMock).toHaveBeenCalledWith(
+ { "$eve.is_trace_content_visible": "true", "$eve.flag": "false" },
+ { allowReservedAttributes: true },
+ );
+ });
+
it("drops undefined values so callers can build sparse attribute maps", async () => {
await setEveAttributes({
"$eve.parent": "wrun_parent",
diff --git a/packages/eve/src/runtime/attributes/emit.ts b/packages/eve/src/runtime/attributes/emit.ts
index e219484f5..096782995 100644
--- a/packages/eve/src/runtime/attributes/emit.ts
+++ b/packages/eve/src/runtime/attributes/emit.ts
@@ -39,7 +39,7 @@ let WARNED_ABOUT_TAG_FAILURE = false;
* - `undefined` entries are dropped so callers can build attribute
* maps with optional fields (`$eve.subagent` is only present on
* subagent roots, for example).
- * - Numbers are stringified (the runtime stores all values as strings).
+ * - Numbers and booleans are stringified (the runtime stores all values as strings).
* - Strings are truncated to {@link EVE_ATTRIBUTE_VALUE_MAX_BYTES} via
* {@link truncateForTag} so a long free-form value (e.g. `$eve.title`)
* can never trip the runtime's per-value byte budget.
diff --git a/packages/eve/src/runtime/attributes/normalize.ts b/packages/eve/src/runtime/attributes/normalize.ts
index 65e6745f6..ef08dd8ad 100644
--- a/packages/eve/src/runtime/attributes/normalize.ts
+++ b/packages/eve/src/runtime/attributes/normalize.ts
@@ -8,7 +8,7 @@
export const EVE_ATTRIBUTE_VALUE_MAX_BYTES = 256;
/** Attribute value accepted by eve's internal attribute builders. */
-export type EveAttributeValue = string | number | undefined;
+export type EveAttributeValue = string | number | boolean | undefined;
/**
* Truncates a string to Workflow's UTF-8 byte budget without splitting
@@ -51,7 +51,7 @@ export function normalizeEveAttributes(
if (value === undefined) {
continue;
}
- const stringValue = typeof value === "number" ? String(value) : value;
+ const stringValue = typeof value === "string" ? value : String(value);
normalized[key] = truncateForTag(stringValue);
}
return normalized;
diff --git a/packages/eve/src/runtime/sessions/runtime-context-keys.ts b/packages/eve/src/runtime/sessions/runtime-context-keys.ts
index 92ac6dc89..708457c9a 100644
--- a/packages/eve/src/runtime/sessions/runtime-context-keys.ts
+++ b/packages/eve/src/runtime/sessions/runtime-context-keys.ts
@@ -4,8 +4,10 @@
*/
import type { ChannelAdapter } from "#channel/adapter.js";
+import type { ChannelAudience } from "#shared/channel-audience.js";
import { getAdapterKind } from "#channel/adapter.js";
import { ContextKey } from "#context/key.js";
+import { buildChannelInstrumentationProjection } from "#channel/instrumentation.js";
import { deserializeRuntimeAdapter } from "#runtime/channels/registry.js";
import {
type DurableCompiledArtifactsSource,
@@ -21,6 +23,7 @@ import {
interface SerializedAdapter {
readonly kind: string;
readonly state: Record<string, unknown>;
+ readonly audience?: ChannelAudience;
}
/** Compiled bundle on the durable context — re-exported under a stable name. */
@@ -34,9 +37,11 @@ interface SerializedBundle {
export const ChannelKey = new ContextKey<ChannelAdapter>("eve.channel", {
codec: {
serialize(adapter): SerializedAdapter {
+ const projection = buildChannelInstrumentationProjection({ adapter });
return {
kind: getAdapterKind(adapter),
state: adapter.state ? { ...adapter.state } : {},
+ audience: projection.metadata.audience,
};
},
deserialize(data, ctx): ChannelAdapter {