Skip to content
Open
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/bump-eve-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"braintrust": minor
---

feat: Bump support for eve

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

Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ span_tree:
│ │ input: {
│ │ "message": "Run the Braintrust Eve instrumentation e2e scenario"
│ │ }
│ │ output: "Started task researcher-<id>. Its result will arrive in a <task_result> message. To send it another message, call researcher again with taskId researcher-<id>."
│ │ output: "Researcher result: Eve instrumentation https://eve.dev/docs/guides/instrumentation"
│ │ metadata: {
│ │ "eve.action_kind": "subagent-call",
│ │ "eve.session_id": "<eve.session_id:1>",
Expand Down Expand Up @@ -750,7 +750,7 @@ span_tree:
│ │ input: {
│ │ "message": "Run the Braintrust Eve instrumentation e2e scenario again"
│ │ }
│ │ output: "Started task researcher-<id>. Its result will arrive in a <task_result> message. To send it another message, call researcher again with taskId researcher-<id>."
│ │ output: "Researcher result: Eve instrumentation https://eve.dev/docs/guides/instrumentation"
│ │ metadata: {
│ │ "eve.action_kind": "subagent-call",
│ │ "eve.session_id": "<eve.session_id:1>",
Expand Down Expand Up @@ -1537,7 +1537,7 @@ span_tree:
│ input: {
│ "message": "Run the Braintrust Eve instrumentation e2e scenario from a traced caller"
│ }
│ output: "Started task researcher-<id>. Its result will arrive in a <task_result> message. To send it another message, call researcher again with taskId researcher-<id>."
│ output: "Researcher result: Eve instrumentation https://eve.dev/docs/guides/instrumentation"
│ metadata: {
│ "eve.action_kind": "subagent-call",
│ "eve.session_id": "<eve.session_id:1>",
Expand Down
23 changes: 14 additions & 9 deletions e2e/scenarios/eve-instrumentation/agent/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ export default defineAgent({
...(process.env.EVE_EXPERIMENTAL_INSTRUMENTATION_PROVIDERS === "1"
? { experimental: { instrumentationProviders: true } }
: {}),
model: defineDynamic({
...(providerInstrumentation ? {} : { fallback: dynamicModel }),
events: {
"step.started": () =>
providerInstrumentation
? { model: dynamicModel, modelContextWindowTokens: 32_768 }
: dynamicModel,
},
} as never),
model: defineDynamic(
// Eve 0.91 resolves dynamic values from a function of the session.
(Number(process.env.EVE_VERSION?.split(".")[1]) >= 91
? () => ({ model: dynamicModel, modelContextWindowTokens: 32_768 })
: {
...(providerInstrumentation ? {} : { fallback: dynamicModel }),
events: {
"step.started": () =>
providerInstrumentation
? { model: dynamicModel, modelContextWindowTokens: 32_768 }
: dynamicModel,
},
}) as never,
),
...(providerInstrumentation ? {} : { modelContextWindowTokens: 32_768 }),
} as never);
4 changes: 2 additions & 2 deletions e2e/scenarios/eve-instrumentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"eve-v0-latest": {
"package": "eve",
"range": ">=0.72 <0.84"
"range": ">=0.72 <0.92"
}
}
}
Expand All @@ -21,7 +21,7 @@
"eve-v0-provider": "npm:eve@0.34.0",
"eve-v0-70": "npm:eve@0.70.0",
"eve-v0-72": "npm:eve@0.72.0",
"eve-v0-latest": "npm:eve@0.83.3",
"eve-v0-latest": "npm:eve@0.91.0",
"zod": "4.3.6"
},
"pnpm": {
Expand Down
44 changes: 37 additions & 7 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.

8 changes: 5 additions & 3 deletions e2e/scenarios/eve-instrumentation/scenario.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,12 @@ describe.sequential("eve instrumentation variants", () => {
scenario: "eve-instrumentation",
testRunId: expect.any(String),
});
// Eve 0.70+ runs subagents as tasks, so the call returns a receipt and
// the result reaches the parent in a later step.
// Earlier task APIs settle the call with a receipt. Eve 0.91's
// call.settled event carries the completed child's result instead.
expect(researcher?.output).toContain(
scenario.tasks ? "Started task researcher-" : "Researcher result",
scenario.tasks && Number(scenario.version.split(".")[1]) < 91
? "Started task researcher-"
: "Researcher result",
);
expect(researcher?.error).toBeUndefined();

Expand Down
99 changes: 69 additions & 30 deletions e2e/scenarios/eve-instrumentation/scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async function main() {
const evePackage = JSON.parse(
await readFile(path.join(evePackageDir, "package.json"), "utf8"),
) as { bin?: string | Record<string, string>; version: string };
process.env.EVE_VERSION = evePackage.version;
const eveBinPath =
typeof evePackage.bin === "string" ? evePackage.bin : evePackage.bin?.eve;
if (!eveBinPath) {
Expand Down Expand Up @@ -100,7 +101,14 @@ async function main() {
[eveBin, "start", "--host", "127.0.0.1", "--port", String(port)],
{
cwd: process.cwd(),
env: process.env,
env: {
...process.env,
// The callback receiver is local. Eve 0.91 requires explicit dev mode
// before accepting loopback callback URLs.
...(Number(process.env.EVE_VERSION?.split(".")[1]) >= 91
? { EVE_DEV: "1" }
: {}),
},
stdio: ["ignore", "pipe", "pipe"],
},
);
Expand Down Expand Up @@ -171,6 +179,9 @@ async function main() {
await runTracedCallerSession(baseUrl);
}
await new Promise((resolve) => setTimeout(resolve, 5000));
} catch (error) {
console.error(output());
throw error;
} finally {
await stopServer(server);
}
Expand Down Expand Up @@ -204,6 +215,9 @@ async function runTracedCallerSession(baseUrl: string): Promise<void> {
async (span) => {
const response = await fetch(`${baseUrl}/eve/v1/session`, {
body: JSON.stringify({
...(Number(process.env.EVE_VERSION?.split(".")[1]) >= 91
? { protocolVersion: 3 }
: {}),
callback: {
callId: "call-traced-caller",
subagentName: "traced-caller",
Expand Down Expand Up @@ -366,38 +380,63 @@ async function streamUntil(
if (!trimmed) {
continue;
}
const event = JSON.parse(trimmed) as {
data?: { childSessionId?: string; message?: string };
type StreamEvent = {
data?: {
childSessionId?: string;
sessionId?: string;
message?: string;
outcome?: string;
error?: { message?: string };
};
type?: string;
};
nextIndex++;
if (
event.type === "step.failed" ||
event.type === "turn.failed" ||
event.type === "session.failed"
) {
throw new Error(
`Eve emitted ${event.type}: ${event.data?.message ?? trimmed}`,
);
}
if (
event.type === "subagent.called" &&
typeof event.data?.childSessionId === "string" &&
!seenSessionIds.has(event.data.childSessionId)
) {
seenSessionIds.add(event.data.childSessionId);
childStreams.push(
streamUntil(
baseUrl,
event.data.childSessionId,
seenSessionIds,
"turn.completed",
).then(() => undefined),
);
const record = JSON.parse(trimmed) as StreamEvent & {
facts?: StreamEvent[];
$eve?: string;
next?: number;
};
if (record.$eve) {
if (record.$eve === "position" && record.next !== undefined) {
nextIndex = record.next;
}
continue;
}
if (event.type === until) {
await Promise.all(childStreams);
return nextIndex;
nextIndex++;
// Eve 0.91 streams commits containing multiple session facts.
for (const event of record.facts ?? [record]) {
if (
event.type === "step.failed" ||
event.type === "turn.failed" ||
event.type === "session.failed" ||
((event.type === "turn.settled" ||
event.type === "session.ended") &&
event.data?.outcome === "failed")
) {
throw new Error(
`Eve emitted ${event.type}: ${event.data?.error?.message ?? event.data?.message ?? trimmed}`,
);
}
const childSessionId =
event.type === "child.opened"
? event.data?.sessionId
: event.type === "subagent.called"
? event.data?.childSessionId
: undefined;
if (childSessionId && !seenSessionIds.has(childSessionId)) {
seenSessionIds.add(childSessionId);
childStreams.push(
streamUntil(
baseUrl,
childSessionId,
seenSessionIds,
"turn.completed",
).then(() => undefined),
);
}
if (event.type === until || event.type === "turn.settled") {
await Promise.all(childStreams);
return nextIndex;
}
}
}
}
Expand Down
Loading
Loading