fix(agent): decouple agent streams from compat

closes #6851
This commit is contained in:
Mario Zechner
2026-07-20 17:54:17 +02:00
parent 3a40794ea1
commit 1235c0ec64
29 changed files with 219 additions and 105 deletions
@@ -49,7 +49,7 @@ function createAssistant(
function useSummaryStreamFn(harness: Harness, summary: string): () => number {
let callCount = 0;
harness.session.agent.streamFn = (model) => {
harness.session.agent.streamFunction = (model) => {
callCount++;
const stream = createAssistantMessageEventStream();
queueMicrotask(() => {
+2 -1
View File
@@ -14,7 +14,7 @@ import type {
FauxResponseStep,
Model,
} from "@earendil-works/pi-ai/compat";
import { registerFauxProvider } from "@earendil-works/pi-ai/compat";
import { registerFauxProvider, streamSimple } from "@earendil-works/pi-ai/compat";
import { AgentSession, type AgentSessionEvent } from "../../src/core/agent-session.ts";
import { AuthStorage } from "../../src/core/auth-storage.ts";
import type { ExtensionRunner } from "../../src/core/extensions/index.ts";
@@ -137,6 +137,7 @@ export async function createHarness(options: HarnessOptions = {}): Promise<Harne
const agent = new Agent({
getApiKey: () => (withConfiguredAuth ? "faux-key" : undefined),
streamFunction: streamSimple,
initialState: {
model,
systemPrompt: options.systemPrompt ?? "You are a test assistant.",
@@ -2,7 +2,7 @@ import { existsSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { Agent } from "@earendil-works/pi-agent-core";
import { fauxAssistantMessage, registerFauxProvider } from "@earendil-works/pi-ai/compat";
import { fauxAssistantMessage, registerFauxProvider, streamSimple } from "@earendil-works/pi-ai/compat";
import { afterEach, describe, expect, it } from "vitest";
import { AgentSession } from "../../../src/core/agent-session.ts";
import { AuthStorage } from "../../../src/core/auth-storage.ts";
@@ -61,6 +61,7 @@ describe("regression #5596: missing configured theme export", () => {
tools: [],
},
convertToLlm,
streamFunction: streamSimple,
});
const session = new AgentSession({
agent,
@@ -17,7 +17,7 @@ describe("issue #6324 branch summary ambient auth", () => {
harnesses.push(harness);
let streamCallCount = 0;
harness.session.agent.streamFn = (model, _context, options) => {
harness.session.agent.streamFunction = (model, _context, options) => {
streamCallCount++;
expect(options?.apiKey).toBeUndefined();