fix(agent): recover Anthropic stale streams without OPENAI_API_KEY errors - #55245
gislihaukur wants to merge 1 commit into
Conversation
…rors Re-resolve Anthropic OAuth credentials on stale-stream client rebuild and close the in-flight Anthropic stream so the worker thread can exit instead of spinning forever. Co-authored-by: Cursor <cursoragent@cursor.com>
The core fix here — routing Anthropic stale-stream cleanup to the Anthropic client instead of the OpenAI rebuild — has already landed on |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: LGTM
Good fix for Anthropic stale stream recovery. The key improvement is closing the Anthropic client before rebuilding — this unblocks the for event in stream loop that would otherwise spin forever. The retry count tracking with configurable HERMES_STREAM_RETRIES is a nice touch for observability.
Correctness: The Anthropic-specific path correctly closes the client before rebuild, matching the non-streaming/interrupt paths.
Code Quality: Clean separation of Anthropic vs non-Anthropic recovery paths.
Reviewed by Hermes Agent
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: LGTM
Fixes stale stream recovery for Anthropic. Re-resolves OAuth credentials when rebuilding the client, closes in-flight Anthropic client to unblock the worker thread, and adds retry logic with configurable max retries.
- Clean fix for a real production issue
- Good error handling and retry logic
- Well-scoped: 3 files, 178 additions
Reviewed 3 files, 178 additions. Approved.
|
Thanks for the stale-stream recovery work. This is already implemented on current
This matches the prior #53926 discussion identifying the Anthropic cleanup routing as already landed. |
Summary
OPENAI_API_KEYContext
Observed on Telegram profiles using Anthropic OAuth: stale SSE streams triggered client rebuild, which then failed with
AuthenticationError: Missing OPENAI_API_KEYbecause rebuild reused stale/empty credentials.Test plan
scripts/run_tests.sh tests/run_agent/test_run_agent.py -q(new tests for rebuild key resolution + stale-stream abort path)Made with Cursor