[Feature]: Include provider, model and account label in the `upstream failure` service.log line

Open Beginner friendly
#9,057 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@EnesKartal is already working on this.

Since Nov 23, 2026.

  • #9078 by @EnesKartal — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript

Research direction

Start in src/server/request-log-terminal-status.ts at the console.warn for upstream failure (around line 108) and confirm provider, model and accountLogLabel are already on the log context type. Read the redaction gate from #8104 and ACCOUNT_LOG_LABEL_RE in src/codex/account-label.ts before adding the three optional fields, then run the existing tests around request-log-terminal-status and check a 429 line in service.log. Done means that line names provider, model and account while no upstream-authored text is printed.

Written by the indexing model from the issue text.

Description

enhancement

Area: Proxy and routing

What are you trying to accomplish?

When several providers or accounts share one proxy, I want to read service.log after a 429 and know which provider, model and account hit the limit.

What prevents this today?

On 2.100.8 an upstream 429 produces this line, and nothing else identifies the request:

2026-11-22T17:48:47.366Z [opencodex] upstream failure type=rate_limit_error code=rate_limit_exceeded

The line has no provider, model, account label or request id. The [combo] ... failed with 429 line that follows names the target, but it only exists for combo routes. Non-combo routes get nothing. usage.jsonl has the full detail (requestId, provider, model, accountLogLabel, per-attempt status), but joining it to service.log by timestamp is ambiguous: concurrent 429s share the same millisecond window, and the log line carries no key to join on.

The line is emitted here, where provider, model and accountLogLabel are already available on the log context:
https://github.com/lidge-jun/opencodex/blob/9e0e298ef9720cfeaa1209f090a68e4d1965d2a1/src/server/request-log-terminal-status.ts#L108

(Added in #8104 and gated in #8744. The fields were not part of its "closed vocabulary" design, which keeps upstream-authored text out of persistent logs.)

What should OpenCodex do?

Append the routing identity to that line, for example:

[opencodex] upstream failure status=429 type=rate_limit_error code=rate_limit_exceeded provider=xai model=grok-4.7 account=o1a2b3c

Only values OpenCodex itself owns are printed: provider id, model id and the existing opaque account label (main, p…, o…). Nothing upstream-authored is added, so the redaction rules from #8104 are unchanged.

Example usage or interface

No new flag. Existing behaviour is the default; only the line above gains three optional key=value fields. A possible follow-up, separate from this request, is the local request id (ocx-…) and the upstream x-request-id (already captured as upstreamRequestId) to make the line joinable with usage.jsonl.

A diff against v2.100.8 is included below: a few lines in src/server/request-log-terminal-status.ts.

Alternatives or workarounds

  • ocx debug / OCX_DEBUG=1 are opt-in and, as far as I can tell, do not change this warning.
  • Reading usage.jsonl works, but only with a timestamp join that is ambiguous under concurrency.
  • #8957 (Antigravity native log traces) is opt-in and Antigravity-specific; this request is the always-on line for every provider.

Additional context

  • Version: @bitkyc08/opencodex 2.100.8 (still the latest release and dev head at the time of writing). OS: macOS.
  • Related: #9032 (open, Anthropic pool 429 leaves a misleading account state) shares the same diagnosability gap. #8398 (auto-resume) and #8993 (live quota in account lists, PR) improve recovery and display, not log attribution.
  • The account= field may be missing on the first failure line if the label is assigned after the first diagnostic is captured; I have not verified the ordering for every provider.
  • All identifiers above are masked or generic; no emails, tokens or paths are included.

Checks

  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.
Suggested patch (against v2.100.8, not compiled or tested)
diff --git a/src/server/request-log-terminal-status.ts b/src/server/request-log-terminal-status.ts
index 921e68948..521f6f519 100644
--- a/src/server/request-log-terminal-status.ts
+++ b/src/server/request-log-terminal-status.ts
@@ -12,6 +12,7 @@ import {
   upstreamErrorMessageFromPayload,
 } from "../lib/errors";
 import { redactSecretString } from "../lib/redact";
+import { ACCOUNT_LOG_LABEL_RE } from "../codex/account-label";
 import { SENT_VALUE_GUARD_SCAN_CHARS, outboundCredentials, type OutboundCredentialRegistry } from "../lib/outbound-credential-registry";
 import { configuredCredentials, containsConfiguredCredentialExcerpt, type ConfiguredCredentials } from "./configured-credentials";
 import { isUntypedBareUpstreamError, reduceBareUpstreamEvidence, wrappedServerErrorStatus, type BareUpstreamError, type BareUpstreamEvidence } from "./bare-upstream-error";
@@ -32,6 +33,10 @@ interface TerminalStatusContext extends UpstreamErrorDiagnostics {
   terminalErrorCode?: typeof CYBER_POLICY_ERROR_CODE;
   committedIncompleteReason?: CommittedIncompleteReason | null;
   upstreamError?: string;
+  /** Routing identity already held by RequestLogContext; printed so a failure line is attributable. */
+  provider?: string;
+  model?: string;
+  accountLogLabel?: string;
 }
 
 export interface UpstreamErrorPayload {
@@ -105,7 +110,10 @@ function noteBoundedDiagnostic(
     // Service logs persist too: print only closed-vocabulary values, never an upstream id or code.
     const { upstreamErrorCode: rawCode, upstreamErrorType: type } = upstreamDiagnosticLogFields(logCtx);
     const code = rawCode !== undefined && KNOWN_BARE_ERROR_CODES.has(rawCode) ? rawCode : undefined;
-    console.warn(`[opencodex] upstream failure${status ? ` status=${status}` : ""}${type ? ` type=${type}` : ""}${code ? ` code=${code}` : ""}`);
+    // provider/model are routing config and the account label is an opaque hash: none is upstream-authored.
+    const account = logCtx.accountLogLabel !== undefined && (logCtx.accountLogLabel === "main" || ACCOUNT_LOG_LABEL_RE.test(logCtx.accountLogLabel)) ? logCtx.accountLogLabel : undefined;
+    console.warn(`[opencodex] upstream failure${status ? ` status=${status}` : ""}${type ? ` type=${type}` : ""}${code ? ` code=${code}` : ""}`
+      + `${logCtx.provider ? ` provider=${logCtx.provider}` : ""}${logCtx.model ? ` model=${logCtx.model}` : ""}${account ? ` account=${account}` : ""}`);
   }
 }
Dominant language
TypeScript
Stars
16.9k
Forks
1.3k
Avg merge
1d 4h
Merged PRs (30d)
814

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lidge-jun/opencodex

All issues in lidge-jun/opencodex

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.