diff --git a/apps/server/src/handlers/task/task.decompose.handler.ts b/apps/server/src/handlers/task/task.decompose.handler.ts index 65111bf..ce75bf6 100644 --- a/apps/server/src/handlers/task/task.decompose.handler.ts +++ b/apps/server/src/handlers/task/task.decompose.handler.ts @@ -117,17 +117,23 @@ export class TaskDecomposeHandler { // Get worker's working directory from instance metadata let workingDirectory: string | undefined; - if (ctx.instanceId) { - const instanceKey = `cb:instance:${ctx.instanceId}`; + // First check if a specific worker was requested in the input metadata + const requestedWorkerId = input.metadata?.workerId; + const workerId = requestedWorkerId || ctx.instanceId; + + if (workerId) { + const instanceKey = `cb:instance:${workerId}`; const instanceMetadata = await redis.pub.hget(instanceKey, 'metadata'); if (instanceMetadata) { try { const metadata = JSON.parse(instanceMetadata); workingDirectory = metadata.workingDirectory; - console.log(`[TaskDecompose] Using working directory from instance ${ctx.instanceId}: ${workingDirectory}`); + console.log(`[TaskDecompose] Using working directory from instance ${workerId}: ${workingDirectory}`); } catch (e) { - console.warn(`[TaskDecompose] Failed to parse instance metadata:`, e); + console.warn(`[TaskDecompose] Failed to parse instance metadata for ${workerId}:`, e); } + } else if (requestedWorkerId) { + console.warn(`[TaskDecompose] Requested worker ${requestedWorkerId} not found or has no metadata`); } } diff --git a/apps/web/src/services/event-client.ts b/apps/web/src/services/event-client.ts index 61b0a33..4c623c7 100644 --- a/apps/web/src/services/event-client.ts +++ b/apps/web/src/services/event-client.ts @@ -83,7 +83,16 @@ export class EventClient { const id = ++this.requestId; // Use longer timeout for context generation and other long-running operations - const longRunningMethods = ['task.context', 'swarm.context', 'swarm.decompose', 'swarm.synthesize', 'swarm.resolve']; + const longRunningMethods = [ + 'task.context', + 'task.decompose', + 'task.create_project', + 'swarm.context', + 'swarm.decompose', + 'swarm.synthesize', + 'swarm.resolve', + 'swarm.create_project' + ]; const isLongRunning = longRunningMethods.includes(method); const originalTimeout = this.config.timeout; @@ -106,8 +115,11 @@ export class EventClient { let lastError: Error | undefined; + // For long-running operations, don't retry automatically as they may not be idempotent + const maxAttempts = isLongRunning ? 1 : this.config.retries + 1; + try { - for (let attempt = 0; attempt <= this.config.retries; attempt++) { + for (let attempt = 0; attempt < maxAttempts; attempt++) { try { const response = await this.sendRequest(request);