fix(pi): inherit default model and api key for embedded agent
This commit is contained in:
@@ -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: [] }))
|
||||
|
||||
Reference in New Issue
Block a user