feat: add native agent with conversation history

This commit is contained in:
William Valentin
2026-02-02 20:56:46 -08:00
parent 70c3960527
commit 69309e58bc
4 changed files with 119 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
import type { ModelClient, Message } from '../../models/types.js';
export interface NativeAgentConfig {
modelClient: ModelClient;
systemPrompt: string;
}
export class NativeAgent {
private modelClient: ModelClient;
private systemPrompt: string;
private history: Message[] = [];
constructor(config: NativeAgentConfig) {
this.modelClient = config.modelClient;
this.systemPrompt = config.systemPrompt;
}
async process(userMessage: string): Promise<string> {
this.history.push({ role: 'user', content: userMessage });
const response = await this.modelClient.chat({
messages: [...this.history],
system: this.systemPrompt,
});
this.history.push({ role: 'assistant', content: response.content });
return response.content;
}
reset(): void {
this.history = [];
}
getHistory(): Message[] {
return [...this.history];
}
}