Skip to content

Restart Claude sessions after authentication failures - #2098

Merged
ymichael merged 2 commits into
mainfrom
bb/fix-provider-authentication-error-thr_2ew3f4ewjp
Aug 20, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/fix-provider-authentication-error-thr_2ew3f4ewjp

Conversation

@ymichael

@ymichael ymichael commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator

What was wrong

Claude Code can emit terminal authentication_failed or oauth_org_not_allowed assistant errors without ending its SDK stream. The Claude bridge treated any still-open stream as writable, so after terminal reauthentication the next turn in the affected bb thread was sent to the old CLI child with stale credentials instead of starting a process that could see the refreshed authentication. This is the root cause reproduced in #2097 and the reported bb thread.

What changed

  • Mark a per-thread Claude session for replacement when the SDK emits either terminal authorization error.
  • Before the next new turn, close that stale query and create a replacement session that resumes the same Claude provider conversation ID.
  • Preserve the failed turn and avoid replacing the session during steering; recovery occurs at the next normal turn boundary.
  • Keep context-preserving session replacements out of the timeline while retaining the warning when provider-side context is actually lost.
  • Add bridge regression coverage for the full failed-message/result and next-turn replacement flow.

This is internal to the Claude provider bridge. There are no host-daemon wire, public plugin API, CLI, configuration, or documentation changes, so HOST_DAEMON_PROTOCOL_VERSION is unchanged.

How you verified

The new regression test fails before the fix because the bridge retains one query, never closes it, and does not create a resumed replacement for the next turn. It passes after the change and verifies that the failed turn remains, the stale query closes exactly once, a second query is launched with the same resume ID, and the next prompt reaches it.

  • pnpm exec turbo run test --filter=bb-plugin-provider-claude-code --force — 18 files and 263 tests passed.
  • pnpm exec turbo run typecheck --filter=bb-plugin-provider-claude-code — 5 Turbo tasks passed.
  • pnpm exec turbo run test --filter=@bb/agent-runtime --force — 31 files and 422 tests passed.
  • pnpm exec turbo run typecheck --filter=@bb/agent-runtime — 4 Turbo tasks passed.
  • git diff --check origin/main...HEAD

Fixes #2097

AGENT GENERATED: by GPT-5

@ymichael
ymichael force-pushed the bb/fix-provider-authentication-error-thr_2ew3f4ewjp branch from 92dd249 to 9d331b8 Compare August 20, 2026 23:22
@ymichael
ymichael merged commit e171ceb into main Aug 20, 2026
13 checks passed
@ymichael
ymichael deleted the bb/fix-provider-authentication-error-thr_2ew3f4ewjp branch August 20, 2026 23:25
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.

Claude threads reuse stale CLI process after terminal authentication failure

1 participant