Skip to content

fix(slack-bot): handle stuck external-authorization sessions gracefully - #1287

Merged
kantord merged 1 commit into
mainfrom
issue-1283
Sep 9, 2026
Merged

kantord merged 1 commit into
mainfrom
issue-1283

Conversation

@kantord

@kantord kantord commented Sep 9, 2026

Copy link
Copy Markdown
Member

Summary

  • A first-use connector needing interactive OAuth consent left the Slack bot's cached session for a thread permanently wedged, showing a generic failure forever.
  • Detect the specific failed_precondition / "has a live external authorization" server error, reply with an actionable message instead of the generic one, and evict the thread's cached session so the next message starts fresh.

Changes

  • bridge.ts: added MecatlBridge.evictSession(threadKey).
  • agentSessions.ts: detect the stuck-authorization ServerError in runPrompt's catch block, reply with an actionable message, evict the session.
  • Tests: eviction behavior in bridge.test.ts, actionable-reply + no-over-fire-on-generic-errors in agentSessions.test.ts.

Fixes #1283

Test plan

  • pnpm run typecheck (sdk/typescript/examples/slack-bot)
  • pnpm run lint
  • pnpm run test — 21/21 passing

Fully or partially written by an AI agent.

🤖 Generated with Claude Code

@kantord
kantord marked this pull request as ready for review September 9, 2026 10:30
@kantord
kantord merged commit c9c0e7b into main Sep 9, 2026
31 of 55 checks passed
@kantord
kantord deleted the issue-1283 branch September 9, 2026 10:49
app.logger.error("mecatl prompt failed", error);
await notifyError(FAILURE_MESSAGE);
if (isStuckExternalAuthorization(error)) {
bridge.evictSession(threadKey);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Evict before releasing the per-thread queue

Could we move this eviction into the queued operation in MecatlBridge.handlePrompt, before the promise stored in #queues settles? Slack can deliver two messages for the same thread while the first is still running. The second call is already chained to #queues; when the first run rejects, that chain starts #runPrompt before this outer catch resumes, so it reuses the stuck session. A burst can also let an older catch delete a newer session. A regression test with two back-to-back calls where the first rejects with this error would pin down the intended "next message starts fresh" behavior.

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.

Slack bot: gracefully handle a stuck 'external authorization' precondition instead of wedging the session forever

3 participants