@gajae-code/agent-core 0.21.0 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.21.1] - 2026-11-17
6
+
7
+ ### Fixed
8
+
9
+ - A run aborted by a canonical publication rejection now logs its underlying cause under a distinct aborted-run diagnostic instead of being reported as a run failure or suppressed as a caller cancellation; the session layer logs the failing operation and its unwrapped cause before aborting, and a deliberate cancellation logs neither entry (#7815).
10
+
5
11
  ## [0.21.0] - 2026-11-16
6
12
 
7
13
  ### Fixed
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/agent-core",
4
- "version": "0.21.0",
4
+ "version": "0.21.1",
5
5
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
6
6
  "homepage": "https://gajae-code.com",
7
7
  "author": "Yeachan-Heo and Gajae Code Contributors",
@@ -32,8 +32,8 @@
32
32
  "fmt": "biome format --write ."
33
33
  },
34
34
  "dependencies": {
35
- "@gajae-code/ai": "0.21.0",
36
- "@gajae-code/utils": "0.21.0",
35
+ "@gajae-code/ai": "0.21.1",
36
+ "@gajae-code/utils": "0.21.1",
37
37
  "@opentelemetry/api": "^1.9.0"
38
38
  },
39
39
  "devDependencies": {
package/src/agent.ts CHANGED
@@ -2436,12 +2436,18 @@ export class Agent {
2436
2436
  return;
2437
2437
  }
2438
2438
  const providerCode = providerFailureCode(err);
2439
- const runtimeFailureCode = abortController.signal.aborted
2440
- ? "aborted"
2441
- : (managedLocalErrorDiagnostic(err)?.errorKind ?? providerCode);
2439
+ const aborted = abortController.signal.aborted;
2440
+ const abortReason = abortController.signal.reason;
2441
+ // A publication rejection aborts the run with its own error. That is a
2442
+ // failure to diagnose, not a caller cancellation, so keep the cause log.
2443
+ // Only the DOMException our own `abort()` installs marks a caller cancellation.
2444
+ // Keying on the name alone would also suppress a publication error that happens
2445
+ // to be named "AbortError".
2446
+ const cancelled = aborted && abortReason instanceof DOMException && abortReason.name === "AbortError";
2447
+ const runtimeFailureCode = aborted ? "aborted" : (managedLocalErrorDiagnostic(err)?.errorKind ?? providerCode);
2442
2448
  const sanitized = sanitizeAgentFailure(err, runtimeFailureCode);
2443
2449
  const errorName = safeErrorName(err);
2444
- if (!abortController.signal.aborted) {
2450
+ if (!aborted) {
2445
2451
  logger.warn("Agent run failed", {
2446
2452
  provider: model.provider,
2447
2453
  model: model.id,
@@ -2449,6 +2455,19 @@ export class Agent {
2449
2455
  status: safeErrorStatus(err),
2450
2456
  ...describeRunFailureForLog(err),
2451
2457
  });
2458
+ } else if (!cancelled) {
2459
+ // The only in-band abort reason is a canonical publication rejection, which
2460
+ // aborts with its own error. Report that cause under a distinct diagnostic
2461
+ // instead of mislabeling it as a run failure. `forceAbort` clears the active
2462
+ // run before this catch can observe it, so a deliberate forced abort never
2463
+ // reaches here, and `abort()` takes the cancellation branch above.
2464
+ logger.warn("Agent run aborted with an underlying failure", {
2465
+ provider: model.provider,
2466
+ model: model.id,
2467
+ code: sanitized.code,
2468
+ status: safeErrorStatus(err),
2469
+ ...describeRunFailureForLog(err),
2470
+ });
2452
2471
  }
2453
2472
 
2454
2473
  const errorMsg: AgentMessage = {
@@ -2465,7 +2484,7 @@ export class Agent {
2465
2484
  totalTokens: 0,
2466
2485
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
2467
2486
  },
2468
- stopReason: abortController.signal.aborted ? "aborted" : "error",
2487
+ stopReason: aborted ? "aborted" : "error",
2469
2488
  errorMessage: sanitized.message,
2470
2489
  errorCode: sanitized.code,
2471
2490
  ...(errorName ? { errorName } : {}),
@@ -2483,7 +2502,7 @@ export class Agent {
2483
2502
  // Store the sanitized message only: the raw provider error may carry request
2484
2503
  // bodies, credentials, or tokens (exact-head review P1).
2485
2504
  this.#state.error = sanitizeAgentFailure(err).message;
2486
- if (!abortController.signal.aborted) {
2505
+ if (!aborted) {
2487
2506
  this.#emit({
2488
2507
  type: "agent_failed",
2489
2508
  // Only the identity-checked local staging diagnostic may assert a
@@ -2493,7 +2512,7 @@ export class Agent {
2493
2512
  });
2494
2513
  }
2495
2514
  this.requestRunTerminal(managedLogicalRunOwner ?? runId, {
2496
- stopReason: abortController.signal.aborted ? "cancelled" : "error",
2515
+ stopReason: aborted ? "cancelled" : "error",
2497
2516
  messages: [errorMsg],
2498
2517
  });
2499
2518
  } finally {