Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-eve-migrate-provider-to-trace-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"braintrust": patch
---

fix(eve): migrate provider to tracePolicy
1 change: 1 addition & 0 deletions e2e/config/pr-comment-scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@
"variants": [
{ "variantKey": "eve-v0", "label": "v0 pinned" },
{ "variantKey": "eve-v0-provider", "label": "v0 provider minimum" },
{ "variantKey": "eve-v0-latest-pinned", "label": "v0 latest pinned" },
{ "variantKey": "eve-v0-latest", "label": "v0 latest" }
]
},
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions e2e/scenarios/eve-instrumentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
},
"dependencies": {
"@openrouter/ai-sdk-provider": "3.0.0",
"ai": "7.0.58",
"ai": "7.0.82",
"eve-v0": "npm:eve@0.22.1",
"eve-v0-latest-pinned": "npm:eve@0.37.1",
"eve-v0-provider": "npm:eve@0.34.0",
"eve-v0-latest": "npm:eve@0.37.1",
"eve-v0-latest": "npm:eve@0.47.6",
"zod": "4.3.6"
}
}
132 changes: 100 additions & 32 deletions e2e/scenarios/eve-instrumentation/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion e2e/scenarios/eve-instrumentation/scenario.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ const eveScenarios = await Promise.all(
provider: true,
variantKey: "eve-v0-provider",
},
{
cassetteKey: "eve-v0-latest",
dependencyName: "eve-v0-latest-pinned",
label: "v0 latest pinned",
provider: true,
variantKey: "eve-v0-latest-pinned",
},
{
cassetteKey: "eve-v0-latest",
dependencyName: "eve-v0-latest",
Expand Down Expand Up @@ -409,8 +416,14 @@ describe.sequential("eve instrumentation variants", () => {
).toHaveLength(1);
}

const snapshotEvents = JSON.parse(
JSON.stringify(events).replace(
/ag_researcher:[0-9a-f]+/g,
"ag_researcher:<id>",
),
) as CapturedLogEvent[];
await matchSpanTreeSnapshot(
events,
snapshotEvents,
resolveFileSnapshotPath(
import.meta.url,
`${scenario.variantKey}.span-tree.json`,
Expand Down
6 changes: 6 additions & 0 deletions js/src/instrumentation/plugins/eve-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ describe("braintrustEveInstrumentation provider lifecycle", () => {
expect(instrumentation).toMatchObject({
capture: "content",
setup,
tracePolicy: expect.any(Function),
});
expect(instrumentation.tracePolicy?.({ audience: "private" })).toEqual({
emit: true,
recordInputs: true,
recordOutputs: true,
});
expect(
Reflect.get(instrumentation, Symbol.for("eve.instrumentation.provider")),
Expand Down
8 changes: 8 additions & 0 deletions js/src/instrumentation/plugins/eve-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ export function createEveInstrumentationProvider(
): EveProviderDefinition {
const bridge = new EveProviderBridge(options.metadata);
return {
// Eve versions before tracePolicy use capture to decide whether provider
// events include content. Newer versions prefer tracePolicy when both are
// present, so keep the deprecated field for backwards compatibility.
capture: "content",
tracePolicy: () => ({
emit: true,
recordInputs: true,
recordOutputs: true,
}),
events: {
"action.completed": (event, context) =>
bridge.handleActionTerminal(event, context),
Expand Down
21 changes: 21 additions & 0 deletions js/src/vendor-sdk-types/eve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,29 @@ type EveProviderHandler<TEvent> = (
context: EveProviderContext,
) => void | PromiseLike<void>;

type EveChannelAudience = "private" | "public" | "unknown";

interface EveTraceCaptureContext {
readonly agentName?: string;
readonly audience: EveChannelAudience;
readonly channelType?: string;
}

type EveTracePolicyDecision =
| { readonly emit: false }
| {
readonly emit: true;
readonly recordInputs: boolean;
readonly recordOutputs: boolean;
};

type EveTraceCapturePolicy = (
trace: EveTraceCaptureContext,
) => EveTracePolicyDecision | boolean;

export interface EveProviderDefinition {
readonly capture?: "content" | "metadata";
readonly tracePolicy?: EveTraceCapturePolicy;
readonly events?: {
readonly "action.completed"?: EveProviderHandler<EveProviderActionTerminalEvent>;
readonly "action.failed"?: EveProviderHandler<EveProviderActionTerminalEvent>;
Expand Down
Loading