tuna-agent 0.1.167 → 0.1.168
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/daemon/index.js +9 -0
- package/package.json +1 -1
package/dist/daemon/index.js
CHANGED
|
@@ -221,6 +221,15 @@ export async function startDaemon(config) {
|
|
|
221
221
|
}
|
|
222
222
|
// Per-agent concurrency: if busy, queue instead of rejecting.
|
|
223
223
|
const agentId = task.agentId || '__default__';
|
|
224
|
+
// Dedup: the API sweep re-dispatches queued tasks every 30s. Without this,
|
|
225
|
+
// a task sent repeatedly while the agent is busy piles up as duplicates in
|
|
226
|
+
// the queue (and would run N times). Ignore if already running or queued.
|
|
227
|
+
const alreadyRunning = Array.from(activeAgentTasks.values()).includes(task.id);
|
|
228
|
+
const alreadyQueued = (agentQueues.get(agentId) || []).some((it) => it.kind === 'task' && it.task.id === task.id);
|
|
229
|
+
if (alreadyRunning || alreadyQueued) {
|
|
230
|
+
console.log(`[Daemon] Task ${task.id} already running/queued — ignoring duplicate dispatch`);
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
224
233
|
if (activeAgentTasks.has(agentId)) {
|
|
225
234
|
enqueueForAgent(agentId, { kind: 'task', task });
|
|
226
235
|
break;
|