fix(pi): inherit default model and api key for embedded agent

This commit is contained in:
William Valentin
2026-02-23 22:06:42 -08:00
parent e8204f5d42
commit 1dfa6ce2b4
3 changed files with 78 additions and 3 deletions
+21
View File
@@ -100,6 +100,27 @@ describe('PiEmbeddedBackend', () => {
}
});
it('surfaces agent state error when no assistant text is produced', async () => {
const mod = createModule(`
export class Agent {
constructor() {
this.state = { messages: [], error: undefined };
}
async prompt() {
this.state.error = "Missing API key for default provider";
}
}
`);
try {
const backend = new PiEmbeddedBackend({ module: mod.moduleUrl, timeoutMs: 2000 });
await expect(backend.process({ prompt: 'hello', history: [] }))
.rejects.toThrow('Missing API key for default provider');
} finally {
mod.cleanup();
}
});
it('throws when module cannot be loaded', async () => {
const backend = new PiEmbeddedBackend({ module: '/definitely/missing/pi-module.mjs', timeoutMs: 2000 });
await expect(backend.process({ prompt: 'hello', history: [] }))