-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Add eve first party eve instrumentation #2203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Luca Forstner (lforst)
wants to merge
11
commits into
main
Choose a base branch
from
lforst/eve-agent-instrumentation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b66e938
feat: Add eve first party eve instrumentation
lforst 3220332
record e2e tests
lforst d969b19
fix
lforst c914a5b
workflow persistence
lforst 83dfd1d
fix race condition
lforst bf0c374
we love input
lforst 8617a1d
system prompt as message instead of instruction
lforst 53d75aa
reuse session as trace root
lforst 7513444
fix
lforst 40f905f
Merge remote-tracking branch 'origin/main' into lforst/eve-agent-inst…
lforst 394ccce
durable tracking
lforst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "braintrust": patch | ||
| --- | ||
|
|
||
| feat: Add Eve instrumentation helpers for Braintrust tracing | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4,392 changes: 4,392 additions & 0 deletions
4,392
e2e/scenarios/eve-instrumentation/__cassettes__/eve-v0-20-0.cassette.json
Large diffs are not rendered by default.
Oops, something went wrong.
1,241 changes: 1,241 additions & 0 deletions
1,241
e2e/scenarios/eve-instrumentation/__snapshots__/eve-instrumentation.span-tree.json
Large diffs are not rendered by default.
Oops, something went wrong.
1,137 changes: 1,137 additions & 0 deletions
1,137
e2e/scenarios/eve-instrumentation/__snapshots__/eve-instrumentation.span-tree.txt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { defineAgent } from "eve"; | ||
| import { createOpenAI } from "@ai-sdk/openai"; | ||
|
|
||
| const openai = createOpenAI({ | ||
| ...(process.env.OPENAI_BASE_URL | ||
| ? { baseURL: process.env.OPENAI_BASE_URL } | ||
| : {}), | ||
| }); | ||
|
|
||
| export default defineAgent({ | ||
| model: openai("gpt-5.4-mini"), | ||
| modelContextWindowTokens: 8_192, | ||
| }); |
15 changes: 15 additions & 0 deletions
15
e2e/scenarios/eve-instrumentation/agent/hooks/braintrust.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { braintrustEveHook } from "braintrust"; | ||
| import { defineState } from "eve/context"; | ||
| import { defineHook } from "eve/hooks"; | ||
|
|
||
| export default defineHook( | ||
| braintrustEveHook({ | ||
| defineState, | ||
| metadata: { | ||
| scenario: "eve-instrumentation", | ||
| ...(process.env.BRAINTRUST_E2E_RUN_ID | ||
| ? { testRunId: process.env.BRAINTRUST_E2E_RUN_ID } | ||
| : {}), | ||
| }, | ||
| }), | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| You are a deterministic fixture agent for Braintrust Eve instrumentation tests. | ||
|
|
||
| For every user task: | ||
|
|
||
| 1. Call the researcher subagent exactly once with the full user message as the | ||
| message. | ||
| 2. After the researcher result is available, call the read tool exactly once with | ||
| the URL https://eve.dev/docs/guides/instrumentation. | ||
| 3. After the read result is available, answer with a single sentence that starts | ||
| with "Final answer from read:" and includes the researcher result, read title, | ||
| URL, and read excerpt. |
14 changes: 14 additions & 0 deletions
14
e2e/scenarios/eve-instrumentation/agent/instrumentation.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { braintrustEveInstrumentation, initLogger } from "braintrust"; | ||
| import { defineState } from "eve/context"; | ||
| import { defineInstrumentation } from "eve/instrumentation"; | ||
|
|
||
| export default defineInstrumentation( | ||
| braintrustEveInstrumentation({ | ||
| defineState, | ||
| setup: ({ agentName }) => { | ||
| initLogger({ | ||
| projectName: process.env.BRAINTRUST_E2E_PROJECT_NAME || agentName, | ||
| }); | ||
| }, | ||
| }), | ||
| ); |
15 changes: 15 additions & 0 deletions
15
e2e/scenarios/eve-instrumentation/agent/subagents/researcher/agent.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { createOpenAI } from "@ai-sdk/openai"; | ||
| import { defineAgent } from "eve"; | ||
|
|
||
| const openai = createOpenAI({ | ||
| ...(process.env.OPENAI_BASE_URL | ||
| ? { baseURL: process.env.OPENAI_BASE_URL } | ||
| : {}), | ||
| }); | ||
|
|
||
| export default defineAgent({ | ||
| description: | ||
| "Research the Eve instrumentation documentation before the parent reads it.", | ||
| model: openai("gpt-5.4-mini"), | ||
| modelContextWindowTokens: 8_192, | ||
| }); |
15 changes: 15 additions & 0 deletions
15
e2e/scenarios/eve-instrumentation/agent/subagents/researcher/hooks/braintrust.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { braintrustEveHook } from "braintrust"; | ||
| import { defineState } from "eve/context"; | ||
| import { defineHook } from "eve/hooks"; | ||
|
|
||
| export default defineHook( | ||
| braintrustEveHook({ | ||
| defineState, | ||
| metadata: { | ||
| scenario: "eve-instrumentation", | ||
| ...(process.env.BRAINTRUST_E2E_RUN_ID | ||
| ? { testRunId: process.env.BRAINTRUST_E2E_RUN_ID } | ||
| : {}), | ||
| }, | ||
| }), | ||
| ); |
7 changes: 7 additions & 0 deletions
7
e2e/scenarios/eve-instrumentation/agent/subagents/researcher/instructions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| You are the deterministic researcher subagent for Braintrust Eve instrumentation tests. | ||
|
|
||
| For every task: | ||
|
|
||
| 1. Call the search tool exactly once with the full task as the query. | ||
| 2. After the search result is available, answer with a single sentence that starts | ||
| with "Researcher result:" and includes the search title and URL. |
16 changes: 16 additions & 0 deletions
16
e2e/scenarios/eve-instrumentation/agent/subagents/researcher/tools/search.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { defineTool } from "eve/tools"; | ||
| import { z } from "zod"; | ||
|
|
||
| export default defineTool({ | ||
| description: "Searches the Eve instrumentation documentation fixture.", | ||
| inputSchema: z.object({ | ||
| query: z.string(), | ||
| }), | ||
| async execute({ query }) { | ||
| return { | ||
| query, | ||
| title: "Eve instrumentation", | ||
| url: "https://eve.dev/docs/guides/instrumentation", | ||
| }; | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { defineTool } from "eve/tools"; | ||
| import { z } from "zod"; | ||
|
|
||
| export default defineTool({ | ||
| description: "Reads a deterministic Eve documentation page fixture.", | ||
| inputSchema: z.object({ | ||
| url: z.string(), | ||
| }), | ||
| async execute({ url }) { | ||
| return { | ||
| excerpt: | ||
| "Eve hooks expose runtime stream events that Braintrust maps into a nested turn trace.", | ||
| section: "Runtime context", | ||
| title: "Eve instrumentation", | ||
| url, | ||
| }; | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { defineTool } from "eve/tools"; | ||
| import { z } from "zod"; | ||
|
|
||
| export default defineTool({ | ||
| description: "Searches the Eve instrumentation documentation fixture.", | ||
| inputSchema: z.object({ | ||
| query: z.string(), | ||
| }), | ||
| async execute({ query }) { | ||
| return { | ||
| query, | ||
| title: "Eve instrumentation", | ||
| url: "https://eve.dev/docs/guides/instrumentation", | ||
| }; | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // @ts-check | ||
| export { filter } from "../ai-sdk-instrumentation/cassette-filter.mjs"; | ||
|
|
||
| /** @type {import("@braintrust/seinfeld").RedactionSpec} */ | ||
| export const redact = [ | ||
| "paranoid", | ||
| { | ||
| redactResponse(response) { | ||
| return { | ||
| ...response, | ||
| headers: Object.fromEntries( | ||
| Object.entries(response.headers).filter( | ||
| ([key]) => | ||
| key.toLowerCase() !== "openai-organization" && | ||
| key.toLowerCase() !== "openai-project", | ||
| ), | ||
| ), | ||
| }; | ||
| }, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "name": "eve-instrumentation-scenario", | ||
| "private": true, | ||
| "type": "module", | ||
| "dependencies": { | ||
| "@ai-sdk/openai": "4.0.0-beta.44", | ||
| "eve": "0.20.0", | ||
| "zod": "4.3.6" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be a minor!