Просмотр исходного кода

fix(llm): honor a carried failure snapshot on any Error

markLlmAdapterFailure gated the own-`failure` data property on instanceof
HarnessError, which drops the validated facts exactly when class identity is
lost — two copies of this package in one process (e.g. a source-plane replay
harness throwing into a lib-plane boot) make the replay-thrown LlmError's
SERVER/AUTH code arrive as UNKNOWN and defeat llm-retry's retryable-code
match. The snapshot is already validated field-by-field and cross-checked
against the error's own code, so honor it on any Error.
Tianyi Cui 2 месяцев назад
Родитель
Сommit
bb0bcf6250
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      packages/llm/llm/src/adapter-failure.ts

+ 6 - 1
packages/llm/llm/src/adapter-failure.ts

@@ -47,7 +47,12 @@ export function markLlmAdapterFailure(
   const error = value instanceof Error
     ? value as Error & { code?: string }
     : new HarnessError(String(value), 'UNKNOWN', { cause: value })
-  const carried = error instanceof HarnessError ? ownFailureSnapshot(error) : undefined
+  // The own `failure` data property is the serializable boundary contract:
+  // validated field-by-field and cross-checked against the error's own code,
+  // then honored on ANY Error — an instanceof gate here would drop the facts
+  // exactly when class identity is lost (a second copy of this package in
+  // the process, e.g. a source-plane test harness over a lib-plane boot).
+  const carried = ownFailureSnapshot(error)
   const failure = carried !== undefined && carried.code === error.code ? carried : Object.freeze({
     message: errorMessage(error),
     code: harnessErrorCode(error),