index.ts
1.41 KB
import { Agent } from 'evoltagent';
import type { ModelConfig } from 'evoltagent';
import { COMMIT_AGENT_SYSTEM_PROMPT } from './prompt';
import { getModelConfig } from '../../utils/config';
import { AGENT_CONTEXT_WINDOW_TOKENS, MAX_OUTPUT_TOKENS } from '../../constants';
export function createCommitAgent(): Agent {
const base = getModelConfig();
// Ollama exposes an OpenAI-compatible `/v1` endpoint. evoltagent's model
// layer only recognises provider tags like 'openai', so the 'ollama' tag we
// use to mark a local model must be mapped to 'openai' here — the
// baseUrl/model/apiKey already point at the local Ollama instance
// (ai-client talks to Ollama the same way). Without this, commit fails with
// "Unsupported provider: ollama" even though the local model is fine.
const provider = base.provider === 'ollama' ? 'openai' : base.provider;
const modelConfig: ModelConfig = {
...base,
provider,
contextWindowTokens: AGENT_CONTEXT_WINDOW_TOKENS,
maxOutputTokens: MAX_OUTPUT_TOKENS,
};
return new Agent({
name: 'CommitAgent',
profile: 'A helpful assistant that commits local changes in a repository.',
system: COMMIT_AGENT_SYSTEM_PROMPT,
tools: ['GitTool.init', 'GitTool.status', 'GitTool.add', 'GitTool.diff', 'GitTool.commit'],
modelConfig,
verbose: 1,
toolcallManagerPoolSize: 1,
});
}