Skip to content

fix: disable banned tokens and handle session resets#11

Closed
Biaogo94 wants to merge 1 commit intoQuorinex:mainfrom
Biaogo94:fix/disable-banned-tokens-and-session-mismatch
Closed

fix: disable banned tokens and handle session resets#11
Biaogo94 wants to merge 1 commit intoQuorinex:mainfrom
Biaogo94:fix/disable-banned-tokens-and-session-mismatch

Conversation

@Biaogo94
Copy link
Copy Markdown

Summary

This change hardens token and session handling for current Freebuff behavior.

Changes

  • disable a token permanently when upstream returns 403 {"status":"banned"} so it stops participating in prewarm, maintenance, and request rotation
  • surface disabled state in health snapshots
  • treat session_model_mismatch as a session/run invalidation signal and retry with a fresh run/session
  • increase retry budget to account for multiple configured auth tokens
  • replace random model-to-agent assignment with a deterministic least-used spread to reduce avoidable model collisions across shared agents

Why

A banned token should not stay in the rotation pool once upstream has already rejected it permanently.

Separately, current upstream behavior can bind a session to a model. When that happens, reusing the same run/session for another model causes session_model_mismatch, so the proxy needs to rotate both session and run instead of repeatedly retrying the same stale state.

Validation

Verified on a live deployment:

  • banned tokens become disabled in /healthz
  • disabled tokens stop creating runs and stop receiving traffic
  • z-ai/glm-5.1 requests continue to succeed
  • session_model_mismatch now triggers run/session invalidation instead of looping on the same stale assignment

Notes

I could not run gofmt locally in this workspace because the Go toolchain is not installed here, but the patch was deployed and exercised on the running service before opening this PR.

@Biaogo94
Copy link
Copy Markdown
Author

Superseded by #13, which consolidates the live-verified session/reset fixes together with the current Responses compatibility work.

@Biaogo94 Biaogo94 closed this Apr 23, 2026
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.

1 participant