fix: align KTX agent tools and repair handling (#73)

This commit is contained in:
Andrey Avtomonov 2026-05-14 00:57:51 +02:00 committed by GitHub
parent ed690ef60c
commit 28b5e2a83e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 113 additions and 45 deletions

View file

@ -40,6 +40,8 @@ describe('AgentRunnerService.runLoop', () => {
it('passes systemPrompt, userPrompt, tools, and step budget through to generateText', async () => {
(generateText as any).mockResolvedValue({ text: 'ok', toolCalls: [], steps: [] });
const repairHandler = vi.fn();
llmProvider.repairToolCallHandler.mockReturnValueOnce(repairHandler);
const tools = { noop: { description: 'noop', inputSchema: {}, execute: vi.fn() } };
await runner.runLoop({
modelRole: 'candidateExtraction',
@ -59,7 +61,9 @@ describe('AgentRunnerService.runLoop', () => {
expect(call.tools).toEqual(tools);
expect(call.stopWhen).toBe(17);
expect(call.temperature).toBe(0);
expect(call.experimental_repairToolCall).toBe(repairHandler);
expect(llmProvider.getModel).toHaveBeenCalledWith('candidateExtraction');
expect(llmProvider.repairToolCallHandler).toHaveBeenCalledWith({ source: 'ktx-agent-runner' });
});
it('returns stopReason=natural when the loop completes without error', async () => {

View file

@ -73,6 +73,9 @@ export class AgentRunnerService {
temperature: 0,
stopWhen: stepCountIs(params.stepBudget),
experimental_telemetry: this.deps.telemetry?.createTelemetry(params.telemetryTags),
experimental_repairToolCall: this.deps.llmProvider.repairToolCallHandler({
source: params.telemetryTags.operationName ?? 'ktx-agent-runner',
}),
messages: built.messages,
tools: built.tools as Record<string, Tool>,
onStepFinish: async () => {