Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(llm-proxy): log a control-api connect failure's cause code once (#720)

Alfredo Lopez8b6310fc4f8c
diff --git a/codex-llm-proxy/src/controlApiClient.ts b/codex-llm-proxy/src/controlApiClient.ts
index 394a51e92..2f09bc522 100644
--- a/codex-llm-proxy/src/controlApiClient.ts
+++ b/codex-llm-proxy/src/controlApiClient.ts
@@ -144,8 +144,10 @@ export class ControlApiClient {
} catch (err) {
if (!isConnectPhaseFailure(err, signal)) throw err
const causeCode = fetchCauseCode(err)
+ // The cause code travels on the error to the attempt line (redeem) or
+ // codex_proxy_finalize_failed's err, so this line records only the hop.
logger.warn(
- { event: 'codex_proxy_control_api_unreachable', causeCode, path },
+ { event: 'codex_proxy_control_api_unreachable', path },
'control API is unreachable'
)
throw new ControlApiClientError(
diff --git a/docs/architecture/codex-subscription-transport-contract.md b/docs/architecture/codex-subscription-transport-contract.md
index 803cd88da..64f721870 100644
--- a/docs/architecture/codex-subscription-transport-contract.md
+++ b/docs/architecture/codex-subscription-transport-contract.md
@@ -639,8 +639,9 @@ request: `ECONNRESET` or another socket error after the request was sent, the
`provider_unavailable`. Finalize failures do not change: they are logged and
never reach the caller.
-The client logs `codex_proxy_control_api_unreachable` with `causeCode` and
-`path`, and the attempt line carries the same `causeCode`.
+The client logs `codex_proxy_control_api_unreachable` with `path` only. The
+cause code is logged on one line only: the attempt line for a redeem, and,
+when both finalize tries fail, the `err` of `codex_proxy_finalize_failed`.
## Evidence
diff --git a/docs/architecture/grok-subscription-transport-contract.md b/docs/architecture/grok-subscription-transport-contract.md
index c5efe106c..cb2f4fd3a 100644
--- a/docs/architecture/grok-subscription-transport-contract.md
+++ b/docs/architecture/grok-subscription-transport-contract.md
@@ -538,10 +538,11 @@ request: `ECONNRESET` or another socket error after the request was sent, the
`provider_unavailable`. Finalize failures do not change: they are logged and
never reach the caller.
-The client logs `grok_proxy_control_api_unreachable` with `causeCode` and
-`path`. The `grok_proxy_attempt_finished` line carries `causeCode` whenever
-the failure is a rejected `fetch`: the undici cause code, such as
-`ECONNREFUSED`, and nothing else from the error.
+The client logs `grok_proxy_control_api_unreachable` with `path` only. The
+`grok_proxy_attempt_finished` line carries `causeCode` whenever the failure
+is a rejected `fetch`: the undici cause code, such as `ECONNREFUSED`, and
+nothing else from the error. When both finalize tries fail, the `err` of
+`grok_proxy_finalize_failed` carries it instead; the hop line never does.
## Feature flags
diff --git a/grok-llm-proxy/src/controlApiClient.ts b/grok-llm-proxy/src/controlApiClient.ts
index 97e40220b..4da035b72 100644
--- a/grok-llm-proxy/src/controlApiClient.ts
+++ b/grok-llm-proxy/src/controlApiClient.ts
@@ -148,8 +148,10 @@ export class ControlApiClient {
} catch (err) {
if (!isConnectPhaseFailure(err, signal)) throw err
const causeCode = fetchCauseCode(err)
+ // The cause code travels on the error to the attempt line (redeem) or
+ // grok_proxy_finalize_failed's err, so this line records only the hop.
logger.warn(
- { event: 'grok_proxy_control_api_unreachable', causeCode, path },
+ { event: 'grok_proxy_control_api_unreachable', path },
'control API is unreachable'
)
throw new ControlApiClientError(