Skip to content

fix(factory): dispatch after Slack clarification#35

Merged
miyaontherelay merged 1 commit into
mainfrom
fix/slack-clarification-dispatch-after-escalation
Jun 22, 2026
Merged

fix(factory): dispatch after Slack clarification#35
miyaontherelay merged 1 commit into
mainfrom
fix/slack-clarification-dispatch-after-escalation

Conversation

@miyaontherelay

Copy link
Copy Markdown
Contributor

Summary

  • dispatch a matched issue after a human answers a pre-dispatch Slack triage escalation, even if factory still considers the issue thin
  • inject the human Slack reply into the spawned implementer/workflow/babysitter agent as an integration event so the agent can acknowledge it and ask follow-ups if needed
  • keep non-routeable escalations blocked at factory-level triage

Testing

  • npm test -- src/orchestrator/factory.test.ts
  • npm run build
  • npm test

Notes

This addresses the AR-287 path where factory repeatedly posted/recognized triage escalation state but never started an agent after the human answered in Slack.

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 714c714f-3a02-40f6-a329-176bb5344a2d

📥 Commits

Reviewing files that changed from the base of the PR and between dd6b21c and 8f8dfb6.

📒 Files selected for processing (2)
  • src/orchestrator/factory.test.ts
  • src/orchestrator/factory.ts

📝 Walkthrough

Walkthrough

FactoryLoop gains a #pendingSlackClarifications map and two new helpers (hasDispatchableRoute, dispatchAfterSlackClarification). When a Slack escalation answer has a dispatchable route, the factory stores the clarification text, dispatches a modified decision (thin=false, confidence='high'), and after dispatch succeeds injects a Slack reply event into running agents. Tests are updated to match the new counters and behavior.

Changes

Slack Clarification Dispatch and Injection

Layer / File(s) Summary
Dispatch readiness and clarification decision helpers
src/orchestrator/factory.ts
Adds hasDispatchableRoute(decision) and dispatchAfterSlackClarification(decision, escalationReason) to check route availability and produce a modified decision with thin=false, confidence='high', and extended rationale. Adds #pendingSlackClarifications private map.
Slack escalation answer handling
src/orchestrator/factory.ts
Updates escalation answer handling to branch on dispatchability: stores pending Slack text, calls #startOrQueueSlackClarifiedDecision, and increments slackTriageAnswersDispatchedWithRemainingEscalation. Introduces #startOrQueueSlackClarifiedDecision for dispatch/queue routing.
Pending clarification injection into agents
src/orchestrator/factory.ts
Adds #injectPendingSlackClarification(record) to inject pending Slack text as a Slack reply event to implementer/workflow/babysitter agents, increment slackTriageAnswersInjectedToAgents, and clear the pending entry. Hooks into non-dry-run dispatch success path via #injectPendingSlackClarification(record).
Test fixture and assertion updates
src/orchestrator/factory.test.ts
Replaces SlackClarifiedTriage with SlackStillEscalatingTriage, renames the test, and updates assertions to check slackTriageAnswersDispatchedWithRemainingEscalation and slackTriageAnswersInjectedToAgents counters.

Sequence Diagram

sequenceDiagram
  participant SlackHuman as Slack Human
  participant FactoryLoop
  participant PendingMap as pendingSlackClarifications
  participant AgentSet as implementer/workflow/babysitter

  SlackHuman->>FactoryLoop: Slack triage answer (with escalationReason)
  FactoryLoop->>FactoryLoop: hasDispatchableRoute(decision)
  FactoryLoop->>PendingMap: store(issueKey, slackText)
  FactoryLoop->>FactoryLoop: dispatchAfterSlackClarification(decision, escalationReason)
  FactoryLoop->>FactoryLoop: `#startOrQueueSlackClarifiedDecision`(clarifiedDecision)
  FactoryLoop->>FactoryLoop: dispatch succeeds → `#injectPendingSlackClarification`(record)
  FactoryLoop->>AgentSet: `#injectSlackReplyEvent`(slackText)
  FactoryLoop->>PendingMap: clear(issueKey)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AgentWorkforce/factory#11: Touches the same Slack human-clarification plumbing in factory.ts/factory.test.ts, specifically how Slack clarification is transformed and injected into agent events.
  • AgentWorkforce/factory#34: Modifies the same Slack triage escalation/clarification flow in FactoryLoop, routing human Slack clarification into triage decisions and dispatch/queue outcomes, with corresponding test updates.

Poem

🐇 A Slack reply lands, still escalating high,
The factory notes it before agents fly.
With thin=false and confidence bright,
The pending map clears once agents ignite.
No override lost — just injected with care,
A rabbit's clean handoff, beyond compare! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(factory): dispatch after Slack clarification' directly and concisely describes the main change: dispatching issues after human Slack clarification.
Description check ✅ Passed The description clearly relates to the changeset, explaining the dispatch behavior after Slack clarification, agent injection, and the specific issue (AR-287) being addressed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/slack-clarification-dispatch-after-escalation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@miyaontherelay miyaontherelay merged commit 17fa068 into main Jun 22, 2026
3 checks passed
@miyaontherelay miyaontherelay deleted the fix/slack-clarification-dispatch-after-escalation branch June 22, 2026 20:08
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