From 1c499a31c5a351b423cc73df805dc8002ad62a1f Mon Sep 17 00:00:00 2001 From: Ali Mohammad Date: Thu, 1 Oct 2026 11:22:11 +0300 Subject: [PATCH] fix(agent-forge): compile and pass against RunUsage (LOU-V5) and tool execute options Exports emptyRunUsage() so hosts that synthesize an ExecutionResult do not hand-build the usage shape. Co-Authored-By: Claude Fable 5.1 --- apps/agent-forge/server/__tests__/debugController.test.ts | 2 +- apps/agent-forge/server/compileHooks.test.ts | 2 +- apps/agent-forge/server/runRegistry.ts | 3 ++- src/execution/index.ts | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/agent-forge/server/__tests__/debugController.test.ts b/apps/agent-forge/server/__tests__/debugController.test.ts index a58e536e8..9ae2cf5a8 100644 --- a/apps/agent-forge/server/__tests__/debugController.test.ts +++ b/apps/agent-forge/server/__tests__/debugController.test.ts @@ -49,7 +49,7 @@ describe('DebugSession', () => { await hookPromise; // Step is one-shot: the next hook call does NOT pause again. - const secondPromise = session.hooks().onLLMResponse?.({} as any, 1); + const secondPromise = session.hooks().onLLMResponse?.({} as any, 1, {} as any); await secondPromise; expect(session.snapshot().paused).toBe(false); }); diff --git a/apps/agent-forge/server/compileHooks.test.ts b/apps/agent-forge/server/compileHooks.test.ts index fe28e7b6f..7bc61895c 100644 --- a/apps/agent-forge/server/compileHooks.test.ts +++ b/apps/agent-forge/server/compileHooks.test.ts @@ -82,7 +82,7 @@ describe('compileHooksFromSpecPolicy', () => { maxSteps: 1, }); - expect(execute).toHaveBeenCalledWith({ email: '[REDACTED]' }, {}); + expect(execute).toHaveBeenCalledWith({ email: '[REDACTED]' }, expect.any(Object)); }); it('compiles a preGenerate hook that actually injects a message when the agent runs', async () => { diff --git a/apps/agent-forge/server/runRegistry.ts b/apps/agent-forge/server/runRegistry.ts index 75a90690b..f090d8111 100644 --- a/apps/agent-forge/server/runRegistry.ts +++ b/apps/agent-forge/server/runRegistry.ts @@ -21,6 +21,7 @@ import { type ExecutionResult, type Message, resumeAfterApproval, + emptyRunUsage, type AgentSpec, } from '@loushy/build-ai-agent'; import { buildAgentFromSpec, extractFlowFromSpec } from './buildAgent'; @@ -616,7 +617,7 @@ export class RunManager extends EventEmitter { text, messages: [{ role: 'assistant', content: text }], toolCalls: [], - usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 }, + usage: emptyRunUsage(), finishReason: 'stop', steps: flowResult.steps, }; diff --git a/src/execution/index.ts b/src/execution/index.ts index c4df09bf8..99a16cd48 100644 --- a/src/execution/index.ts +++ b/src/execution/index.ts @@ -47,3 +47,4 @@ export type { RunDoneEvent, } from './agentEvents'; export type { AgentRun } from './agentRun'; +export { emptyRunUsage } from './runUsage';