fix(agent): restore streamFn extension compatibility

Keep streamFn required for typed callers while preserving the legacy runtime fallback for extensions that omit it.\n\nfixes #6915
This commit is contained in:
Mario Zechner
2026-07-21 18:34:56 +02:00
parent b142504125
commit b9e5c5d941
26 changed files with 210 additions and 88 deletions
+7 -7
View File
@@ -29,7 +29,7 @@ const agent = new Agent({
systemPrompt: "You are a helpful assistant.",
model,
},
streamFunction: models.streamSimple.bind(models),
streamFn: models.streamSimple.bind(models),
});
agent.subscribe((event) => {
@@ -199,7 +199,7 @@ const agent = new Agent({
followUpMode: "one-at-a-time",
// Required stream function
streamFunction: models.streamSimple.bind(models),
streamFn: models.streamSimple.bind(models),
// Session ID for provider caching
sessionId: "session-123",
@@ -386,7 +386,7 @@ Handle custom types in `convertToLlm`:
```typescript
const agent = new Agent({
streamFunction: models.streamSimple.bind(models),
streamFn: models.streamSimple.bind(models),
convertToLlm: (messages) => messages.flatMap(m => {
if (m.role === "notification") return []; // Filter out
return [m];
@@ -457,7 +457,7 @@ For browser apps that proxy through a backend:
import { Agent, streamProxy } from "@earendil-works/pi-agent-core";
const agent = new Agent({
streamFunction: (model, context, options) =>
streamFn: (model, context, options) =>
streamProxy(model, context, {
...options,
authToken: "...",
@@ -489,13 +489,13 @@ const config: AgentLoopConfig = {
const userMessage = { role: "user", content: "Hello", timestamp: Date.now() };
const streamFunction = models.streamSimple.bind(models);
for await (const event of agentLoop([userMessage], context, config, undefined, streamFunction)) {
const streamFn = models.streamSimple.bind(models);
for await (const event of agentLoop([userMessage], context, config, undefined, streamFn)) {
console.log(event.type);
}
// Continue from existing context
for await (const event of agentLoopContinue(context, config, undefined, streamFunction)) {
for await (const event of agentLoopContinue(context, config, undefined, streamFn)) {
console.log(event.type);
}
```