feat: Auto-resume idle agents for inter-agent conversations

When an agent asks a question via `cw ask` targeting an idle agent,
the conversation router now auto-resumes the idle agent's session so
it can answer. Previously, questions to idle agents sat unanswered
forever because target resolution only matched running agents.

Changes:
- Add `resumeForConversation()` to AgentManager interface and implement
  on MultiProviderAgentManager (mirrors resumeForCommit pattern)
- Relax createConversation target resolution: prefer running, fall back
  to idle (was running-only)
- Trigger auto-resume after conversation creation for idle targets
- Add concurrency lock (conversationResumeLocks Set) to prevent
  double-resume race conditions
This commit is contained in:
Lukas May
2026-03-03 13:29:39 +01:00
parent 938700d45d
commit 9edc93a268
7 changed files with 116 additions and 7 deletions

View File

@@ -254,6 +254,11 @@ export interface TestHarness {
*/
getPendingQuestions(agentId: string): Promise<PendingQuestions | null>;
/**
* Resume an idle agent to answer a conversation (mock: always returns false).
*/
resumeForConversation(agentId: string, conversationId: string, question: string, fromAgentId: string): Promise<boolean>;
/**
* Get events by type.
*/
@@ -505,6 +510,9 @@ export function createTestHarness(): TestHarness {
getPendingQuestions: (agentId: string) => agentManager.getPendingQuestions(agentId),
resumeForConversation: (agentId: string, conversationId: string, question: string, fromAgentId: string) =>
agentManager.resumeForConversation(agentId, conversationId, question, fromAgentId),
getEventsByType: (type: string) => eventBus.getEventsByType(type),
getEmittedEvents: (type: string) => eventBus.getEventsByType(type),