Skip to content
Draft
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
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
OPENROUTER_API_KEY='add your openrouter api key here'
EXA_SEARCH_API_KEY='add your exa search api key here'
EXA_SEARCH_API_KEY='add your exa search api key here'
AGENTPOND_ENABLED=false
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,31 @@ bun run dev

Visit `http://localhost:3000` to see your app.

### Optional AgentPond tracing

To export OpenInference AI traces directly to a private Vercel Blob store,
initialize AgentPond 0.6 from the project root:

```bash
npx agentpond@0.6.0 init --platform vercel
```

Follow the generated prompt, connect a private Blob store to the Vercel
project, enable Vercel System Environment Variables, and set
`AGENTPOND_ENABLED=true`. After running a research request:

The AI SDK telemetry settings explicitly enable `recordInputs` and
`recordOutputs`. This records input and output values for each instrumented
call, which may include prompts, messages, tool data, and generated content. A
private Blob store restricts access but does not redact these values. Review
the [Vercel AI SDK telemetry documentation](https://ai-sdk.dev/docs/ai-sdk-core/telemetry)
before enabling tracing.

```bash
npx agentpond@0.6.0 sync
npx agentpond@0.6.0 traces list --limit 10
```

## 🌟 Show Your Support

Give a ⭐️ if this project helped you!
Expand Down
145 changes: 144 additions & 1 deletion bun.lock

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions instrumentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export async function register() {
if (
process.env.NEXT_RUNTIME === "nodejs" &&
process.env.AGENTPOND_ENABLED === "true"
) {
const { registerAgentPond } = await import("./src/lib/agentpond");
registerAgentPond();
}
}
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@
"lint": "eslint ."
},
"dependencies": {
"@agentpond/vercel": "0.5.0",
"@ai-sdk/react": "^3.0.0",
"@arizeai/openinference-vercel": "2.8.1",
"@hookform/resolvers": "^5.0.0",
"@openrouter/ai-sdk-provider": "^2.8.1",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/api-logs": "0.220.0",
"@opentelemetry/instrumentation": "0.220.0",
"@opentelemetry/resources": "2.9.0",
"@opentelemetry/sdk-logs": "0.220.0",
"@opentelemetry/sdk-metrics": "2.9.0",
"@opentelemetry/sdk-trace-base": "2.9.0",
"@radix-ui/react-accordion": "^1.2.12",
"@radix-ui/react-collapsible": "^1.1.12",
"@radix-ui/react-label": "^2.1.8",
Expand All @@ -22,6 +30,7 @@
"@radix-ui/react-slot": "^1.2.4",
"@radix-ui/react-tabs": "^1.1.13",
"@radix-ui/react-tooltip": "^1.2.8",
"@vercel/otel": "2.1.3",
"ai": "^6.0.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
Expand Down
12 changes: 11 additions & 1 deletion src/app/api/deep-research/model-caller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ researchState: ResearchState,activityTracker: ActivityTracker ): Promise<T | str
if(schema){
// AI SDK v6: Use generateText with Output.object() instead of generateObject
const { output, usage } = await generateText({
experimental_telemetry: {
isEnabled: process.env.AGENTPOND_ENABLED === "true",
recordInputs: true,
recordOutputs: true,
},
model: openrouter(model),
prompt,
system,
Expand All @@ -33,6 +38,11 @@ researchState: ResearchState,activityTracker: ActivityTracker ): Promise<T | str
}else{

const { text, usage } = await generateText({
experimental_telemetry: {
isEnabled: process.env.AGENTPOND_ENABLED === "true",
recordInputs: true,
recordOutputs: true,
},
model: openrouter(model),
prompt,
system,
Expand All @@ -55,4 +65,4 @@ researchState: ResearchState,activityTracker: ActivityTracker ): Promise<T | str
}

throw lastError || new Error(`Failed after ${MAX_RETRY_ATTEMPTS} attempst!`)
}
}
7 changes: 6 additions & 1 deletion src/app/api/generate-questions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const clarifyResearchGoals = async (topic: string) => {
try{
// AI SDK v6: Use generateText with Output.object() instead of generateObject
const { output } = await generateText({
experimental_telemetry: {
isEnabled: process.env.AGENTPOND_ENABLED === "true",
recordInputs: true,
recordOutputs: true,
},
model: openrouter("meta-llama/llama-3.3-70b-instruct"),
prompt,
output: Output.object({
Expand Down Expand Up @@ -58,4 +63,4 @@ export async function POST(req: Request){



}
}
21 changes: 21 additions & 0 deletions src/lib/agentpond.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import "server-only";

import { createVercelSpanExporter } from "@agentpond/vercel";
import {
isOpenInferenceSpan,
OpenInferenceSimpleSpanProcessor,
} from "@arizeai/openinference-vercel";
import { registerOTel } from "@vercel/otel";

export function registerAgentPond() {
registerOTel({
serviceName: "deep-research-ai-agent",
spanProcessors: [
new OpenInferenceSimpleSpanProcessor({
exporter: createVercelSpanExporter(),
spanFilter: isOpenInferenceSpan,
reparentOrphanedSpans: true,
}),
],
});
}