Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

fix(agent): exclude cancellation from normal recovery accounting

wyt83b2b94a5f9e
diff --git a/src/main/model/core-agent/client.ts b/src/main/model/core-agent/client.ts
index 3f24c848..ef502a8b 100644
--- a/src/main/model/core-agent/client.ts
+++ b/src/main/model/core-agent/client.ts
@@ -1059,7 +1059,7 @@ export function recordModelRawEventForLog(stats: ModelRunLogDiagnostics, ev: unk
`tool=${safeToolNameForLog(e.name)} call=${maskId(e.id)} error=${e.isError ? 'true' : 'false'}${e.errorSeverity ? ` severity=${e.errorSeverity}` : ''}`,
);
const runtimeException = ['tool_execution_exception', 'tool_execution_stalled', 'tool_result_processing_exception'].includes(String(e.errorCode || ''));
- recordToolResultRecovery(stats, e, !!e.isError && e.errorSeverity !== 'recoverable' && !runtimeException);
+ recordToolResultRecovery(stats, e, !!e.isError && !e.executionCancelled && e.errorSeverity !== 'recoverable' && !runtimeException);
const planMutation = safePlanMutationForLog(e);
const providerRound = stats.providerRounds.at(-1);
if (planMutation && providerRound) {
diff --git a/test/main/model/core-agent/client.test.ts b/test/main/model/core-agent/client.test.ts
index f5e2e563..c7073133 100644
--- a/test/main/model/core-agent/client.test.ts
+++ b/test/main/model/core-agent/client.test.ts
@@ -465,6 +465,34 @@ describe('core-agent client skill sandbox env', () => {
});
});
+ it('keeps user-cancelled tools out of returned-error and recovery diagnostics', async () => {
+ const client = await import('../../../../src/main/model/core-agent/client');
+ const stats = client.createModelRunLogDiagnostics(1000);
+
+ client.recordModelRawEventForLog(stats, {
+ type: 'tool_start', id: 'cancelled-read', name: 'read_file', input: { path: 'one.txt' },
+ }, 1010);
+ // The real core runner marks its abort receipt as an error for the tool
+ // protocol and separately supplies this authoritative lifecycle fact.
+ client.recordModelRawEventForLog(stats, {
+ type: 'tool_end', id: 'cancelled-read', name: 'read_file', isError: true,
+ executionCancelled: true, result: 'Tool execution aborted: Run aborted',
+ }, 1020);
+ expect(client.summarizeModelRunForLog(stats, 1021)).toMatchObject({
+ toolResultErrors: 0, toolResultErrorsRecovered: 0, toolResultErrorsUnresolved: 0,
+ });
+
+ client.recordModelRawEventForLog(stats, {
+ type: 'tool_start', id: 'later-read', name: 'read_file', input: { path: 'two.txt' },
+ }, 1030);
+ client.recordModelRawEventForLog(stats, {
+ type: 'tool_end', id: 'later-read', name: 'read_file', isError: false, result: 'file contents',
+ }, 1040);
+ expect(client.summarizeModelRunForLog(stats, 1050)).toMatchObject({
+ toolResultErrors: 0, toolResultErrorsRecovered: 0, toolResultErrorsUnresolved: 0,
+ });
+ });
+
it('recovers an invalid selector-less call only from a later retry with the same argument shape', async () => {
const client = await import('../../../../src/main/model/core-agent/client');
const stats = client.createModelRunLogDiagnostics(1000);