This commit is contained in:
seb
2026-10-05 22:27:20 +02:00
parent 7d55b9774a
commit 4b4b03172a
5 changed files with 229 additions and 18 deletions

View File

@@ -183,17 +183,16 @@ class LLMOrbiter {
tools: toolSpecs.length ? toolSpecs : undefined,
signal: runSignal,
extraBody,
onStatus: (s) => call(onStatus, s),
onStatus: (...args) => call(onStatus, ...args),
onContent: (...args) => call(onContent, ...args),
onReasoning: (r) => call(onReasoning, r),
});
// Accumulate usage & emit event per LLM call completed
// Accumulate usage per LLM call completed
const callUsage = this._addUsage(usage, completion.usage);
if (completion.usage) {
rawUsages.push(completion.usage);
}
await call(onUsage, callUsage);
const toolCalls = completion.tool_calls;
const content = completion.content;
@@ -202,6 +201,7 @@ class LLMOrbiter {
// When there is no response (neither tool calls nor content), the loop shall continue.
if (!hasToolCalls && !hasContent) {
await call(onUsage, callUsage);
continue;
}
@@ -217,6 +217,7 @@ class LLMOrbiter {
// No tool calls → done
if (!hasToolCalls) {
finalContent = content;
await call(onUsage, callUsage);
break;
}
@@ -318,6 +319,8 @@ class LLMOrbiter {
recordToolResult(callItem, result);
}
await call(onUsage, callUsage);
if (hasDirectReturn) break;
if (pendingAppendedMessages.length > 0) {