Skip to content

feat: log forwarded requests under --verbose#2

Merged
skishore23 merged 2 commits into
skishore23:mainfrom
mattmillerai:feat/verbose-request-diagnostics
Jun 11, 2026
Merged

feat: log forwarded requests under --verbose#2
skishore23 merged 2 commits into
skishore23:mainfrom
mattmillerai:feat/verbose-request-diagnostics

Conversation

@mattmillerai

Copy link
Copy Markdown
Contributor

Extends the existing --verbose flag (which today only logs rotations/errors) to also print, per forwarded request:

[clauden] → POST /v1/messages model=claude-sonnet-4-6 stream=true body=48K beta=context-1m-2025-08-07,...
[clauden] ← 200 via you@example.com

Why

Useful for proxy debugging in general, but specifically a diagnostic for a compaction issue seen when driving Claude Code through the proxy (auto-compacting on nearly every tool call). The anthropic-beta header is the tell:

  • If it carries a context-1m-* value, the client negotiated the 1M-token context window.
  • If it's absent, the client is assuming the 200K default and will auto-compact far sooner — the suspected cause, since the proxy sets a placeholder ANTHROPIC_API_KEY that puts Claude Code in API-key mode rather than subscription mode.

The per-response status line surfaces account flapping at the same time, which invalidates the upstream prompt cache and compounds the cost.

Notes

  • Pure addition behind --verbose; default behavior unchanged.
  • cargo build, cargo clippy --all-targets clean; 18 unit + 5 integration tests pass.

🤖 Generated with Claude Code

mattmillerai and others added 2 commits June 10, 2026 19:03
Extends --verbose to print a one-line summary of each forwarded request
(method, path, model, stream flag, body size, and the `anthropic-beta` header)
plus a per-response status line showing which account served it.

The `anthropic-beta` header is the diagnostic payload: a `context-1m-*` value
means the client negotiated the 1M-token context window; its absence means the
client is assuming the 200K default and will auto-compact far sooner. The
response line makes account flapping — which invalidates the upstream prompt
cache — visible at the same time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
When an account hits 429/402/529, --verbose now prints the upstream response
body (truncated) and the reported 5h/7d utilization headers, not just the
status. This distinguishes a real quota limit (high utilization, rate_limit_error
body) from an auth/request-shape rejection that merely uses a 429 status — the
two were indistinguishable from the status code alone.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@skishore23 skishore23 merged commit 9409fa5 into skishore23:main Jun 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants