@bman654/clodex 2.8.5 → 2.10.0

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/README.md CHANGED
@@ -339,22 +339,99 @@ clodex --version # version
339
339
  SDK reports that it omitted the tier for a model, clodex warns once and the
340
340
  backend default remains in use.
341
341
  - **Outbound proxy:** when `HTTP_PROXY`/`HTTPS_PROXY` (and optionally `NO_PROXY`) are set in clodex's environment, all clodex-originated network calls honor them — OAuth sign-in and token refresh, model-list and models.dev refreshes, upstream OpenAI API calls, and the ChatGPT/Codex OAuth WebSocket transport (tunneled via HTTP CONNECT).
342
- - **Upstream retries:** set `CLODEX_UPSTREAM_MAX_RETRIES` to an integer from
343
- `0` through `5` to override the SDK's default of two retries for retryable
344
- provider failures. `0` disables retries. The SDK honors valid
345
- `retry-after`/`retry-after-ms` headers and otherwise uses exponential
346
- backoff. Larger integers clamp to `5` with a one-time warning because a sixth
347
- retry cannot complete before the translated streaming paths' 120-second
348
- no-data timeout. Unset, empty, or malformed values preserve the default. A
349
- stream that fails after output begins cannot be replayed safely and still
350
- terminates the request. The same setting covers requests passed straight
351
- through to Anthropic, which replay once by default. Only a request that went
352
- out on a pooled connection the far end had already closed, and that received
353
- no part of a response, is replayed there; anything else is reported as it
354
- happens. Setting Claude Code's own `CLAUDE_CODE_MAX_RETRIES=0` also disables
355
- the passthrough replay, so telling the client never to resend a request is
356
- not quietly undone one layer down. Recovered requests appear in the inference
357
- log as `response_retried`.
342
+ - **Provider timeouts:** `CLODEX_UPSTREAM_IDLE_TIMEOUT_MS` controls how long an
343
+ SDK-backed translated stream may produce no event (default `120000`; range
344
+ `10000`–`3600000` ms). `CLODEX_UPSTREAM_TOTAL_TIMEOUT_MS` limits each call
345
+ clodex makes to a configured provider, including non-streaming calls (default
346
+ `600000`; range `60000`–`21600000` ms). An authentication refresh can start a
347
+ new call with a fresh timer, so this is not an end-to-end route deadline. Set
348
+ both variables on the process serving the request: the embedded server
349
+ started by `clodex claude`, or a standalone `clodex server`. `clodex-claude`
350
+ only connects to an existing server, so setting them on that wrapper does not
351
+ reconfigure the server. Empty values use the defaults, malformed values are
352
+ ignored, and integers outside the supported ranges clamp to the nearest
353
+ bound. Clodex warns once for each malformed, clamped, or inconsistent setting
354
+ when a request first resolves it; `clodex claude` displays that parent notice
355
+ after Claude Code exits. The total timeout can never be shorter than the idle
356
+ timeout: increasing only the idle timeout raises the default total to match,
357
+ while an explicit shorter total lowers the idle timeout. The 10s/1m floors
358
+ avoid near-immediate termination; the 1h/6h ceilings allow deliberately long
359
+ calls without leaving stalls attached indefinitely. At either deadline,
360
+ clodex aborts the SDK call; cancellation is cooperative, so a provider
361
+ transport that ignores the abort signal can settle later. These are
362
+ server-side limits, and callers may stop sooner. Claude Code currently
363
+ defaults to about 180s of downstream byte silence in proxy mode and 300s in
364
+ endpoint mode, with
365
+ a 30m byte-watchdog ceiling. In Claude Code's environment, `API_TIMEOUT_MS`
366
+ controls the pre-header deadline; `CLAUDE_STREAM_IDLE_TIMEOUT_MS` and
367
+ `CLAUDE_BYTE_STREAM_IDLE_TIMEOUT_MS` control stream silence. Waits beyond 30m
368
+ also require `CLAUDE_ENABLE_BYTE_WATCHDOG=false`. With a standalone server,
369
+ set those client variables on the Claude Code process, not the server.
370
+ - **Upstream retries:** clodex retries retryable failures on SDK-backed
371
+ provider calls up to `5` times by default. Set
372
+ `CLODEX_UPSTREAM_MAX_RETRIES` to a non-negative integer to override it; `0`
373
+ disables retries. The default and configuration ceiling
374
+ are derived from the resolved idle timeout and the SDK's fallback 2s, 4s, 8s,
375
+ … backoff, so a shorter idle timeout automatically lowers both. The ceiling
376
+ is `5` at the default timeout and can rise to `10` at the maximum. Larger
377
+ integers clamp with a one-time warning that names the active idle timeout.
378
+ On a genuinely unavailable provider, five retries can add roughly 62s of
379
+ fallback backoff instead of the SDK default's roughly 6s; the longer wait is
380
+ deliberate so transient failures have more time to recover. Provider
381
+ `retry-after` hints and time spent in failed attempts can mean fewer retries
382
+ start before a streaming idle deadline; the shared abort signal still
383
+ interrupts backoff when that deadline fires. If a deadline interrupts a
384
+ retry delay, clodex preserves the provider failure that prompted the retry;
385
+ if a currently active call is silent, clodex reports the timeout instead.
386
+ Unset, empty, or malformed values preserve the clodex default. The SDK only
387
+ retries before model output is exposed downstream; a stream that fails after
388
+ partial output cannot be
389
+ replayed safely and still terminates the request. The same
390
+ retry setting also controls proxy mode's raw HTTP MITM path, which replays
391
+ once by default and retains an independent ceiling of `5`. Only a request
392
+ sent on a pooled connection the far end had already closed, with no response
393
+ received, is replayed there; other direct raw relays add no transport-failure
394
+ replay (an OAuth 401 refresh can still start a new authenticated call). The
395
+ timeout settings add no timers to any raw relay. A valid
396
+ `CLODEX_UPSTREAM_MAX_RETRIES` value takes precedence on the HTTP MITM path;
397
+ otherwise, Claude Code's own `CLAUDE_CODE_MAX_RETRIES=0` disables that replay
398
+ so telling the client never to resend a request is not quietly undone one
399
+ layer down.
400
+ Recovered requests appear in the inference log as `response_retried`.
401
+ - **Connection pacing (ChatGPT/Codex plans):** when many agents run at once,
402
+ clodex spaces out the new connections it opens to OpenAI, which should make a
403
+ burst of parallel work less likely to trip OpenAI's own rate limit. (In the
404
+ traffic we sampled, the rejections clustered in the busiest minutes; that the
405
+ rate is what triggers them is a reasonable reading of that, not something we
406
+ can prove.) A follow-up turn that can reuse the connection it already has is
407
+ never delayed by this;
408
+ what goes through the limiter is work that needs a *new* connection — a first
409
+ turn, a conversation that branched, or several agents running at once. The
410
+ default is 60 new connections a minute, with an allowance of 10 opened back
411
+ to back after a quiet spell.
412
+ **This is a real throughput ceiling, not a brief pause.** One new connection
413
+ per second means that if you run many agents at once and each needs its own
414
+ connection, they end up sharing that budget: roughly 20 agents settle at
415
+ about 20 seconds per turn instead of a few seconds. That is the trade — you
416
+ wait longer, in exchange for a lower chance of losing turns to rate-limit
417
+ errors. It reduces that risk rather than removing it: clodex cannot see
418
+ OpenAI's actual limit, and under a heavy enough fan-out pacing can itself
419
+ answer a turn with a rate-limit response. Work over the
420
+ rate is queued for a few seconds, and anything still over is answered with
421
+ the same "try again shortly" response OpenAI itself would return, which
422
+ clodex retries for you with backoff. Set
423
+ `CLODEX_WS_MAX_NEW_CONNECTIONS_PER_MIN` to another whole number between `1`
424
+ and `600` to change the rate, or to `0` to turn pacing off. Higher values
425
+ clamp to `600` with a one-time warning, and an unreadable value is reported
426
+ once and ignored. If you have turned retries off with
427
+ `CLODEX_UPSTREAM_MAX_RETRIES=0`, pacing never refuses a request — but it also
428
+ stops limiting once its initial allowance is used up, because there would be
429
+ nothing left to retry a refused request. The same applies at very low rates:
430
+ if clodex cannot retry a turned-away request for long enough to reach the
431
+ next free connection slot — which is the case around 1 or 2 connections a
432
+ minute at the default timeouts — it admits the excess late rather than
433
+ failing it, and says so once. Turning a rate that low into hard failures
434
+ would manufacture the errors this feature exists to reduce.
358
435
 
359
436
  ## Known limitations
360
437