Pi Agent
Trace a Pi Agent with Neatlogs (TypeScript).
Wrap a Pi Agent with piAgentHooks to capture its runs, model calls, and tool calls.
Prerequisites
npm install neatlogs@latest @mariozechner/pi-agent-core @mariozechner/pi-aiUsage
import { init, shutdown } from 'neatlogs';
import { piAgentHooks } from 'neatlogs/pi-agent';
import { Agent } from '@mariozechner/pi-agent-core';
import { getModel } from '@mariozechner/pi-ai';
async function main() {
await init({ apiKey: process.env.NEATLOGS_API_KEY, workflowName: 'pi-agent-demo' });
const agent = piAgentHooks(
new Agent({
initialState: {
systemPrompt: 'Be concise.',
model: getModel('openai', 'gpt-4o'),
tools: [],
messages: [],
},
}),
);
await agent.prompt('In one sentence, what is Pi Agent?');
await shutdown();
}
main().catch(console.error);