From d163fb571f7087070e388d71b7b99657b09f2b9f Mon Sep 17 00:00:00 2001 From: Michael Slezak Date: Thu, 26 Mar 2026 16:54:23 -0600 Subject: [PATCH] Update README --- README.md | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 49959cb..55619be 100644 --- a/README.md +++ b/README.md @@ -19,17 +19,19 @@ npm i llpsdk ```typescript import { LLPClient } from 'llpsdk'; import { config } from 'dotenv'; +import { createAgent } from 'my_app'; async function main() { config(); // Initialize the client const client = new LLPClient('my-agent', process.env.LLP_API_KEY ?? ''); - // Define a callback handler for processing messages - client.onMessage(async (_session, msg) => { + // Define a callback handler agent initialization and for processing messages + client.onStart(() => { createAgent() }); + client.onMessage(async (agent, msg, _annotater) => { // Process the prompt with your agent. // Replace this with your own processing logic. - const response = msg.prompt; + const response = agent.generate(msg.prompt); // You must return a response return msg.reply(response); @@ -70,8 +72,7 @@ const weatherTool = tool( const client = new LLPClient>('my-agent', process.env.LLP_API_KEY ?? ''); -client.onStart((session, presence) => { - if (presence.status === 'available') { +client.onStart(() => { return createAgent({ model, tools: [weatherTool], @@ -80,12 +81,7 @@ client.onStart((session, presence) => { } }); -client.onMessage(async (session, msg) => { - const agent = session.data; - if (!agent) { - throw new Error(`No agent initialized for session ${session.id}`); - } - +client.onMessage(async (agent, msg, annotater) => { const result = await agent.invoke( { messages: [{ role: 'user', content: msg.prompt }], @@ -93,7 +89,7 @@ client.onMessage(async (session, msg) => { { context: { llpMessage: msg, - llpClient: session, + llpClient: agent, }, }, ); @@ -107,9 +103,6 @@ The middleware requires LLP runtime context with: - `llpMessage`: the inbound `TextMessage` - `llpClient`: the session or client object used to send tool-call annotations -`onStart()` can return a typed session value that the SDK stores on `session.data`. -`onPresence()` remains available as a compatibility alias, but `onStart()` is the preferred API. - ## Development ```bash