π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(hetero-agent): don't treat an inline tool's task_notification as a post-task summary (#16050)
Arvin Xuba5571cb4a5c
diff --git a/packages/heterogeneous-agents/src/adapters/claudeCode.test.ts b/packages/heterogeneous-agents/src/adapters/claudeCode.test.tsindex 2b07ff684ad..d810593dcc1 100644--- a/packages/heterogeneous-agents/src/adapters/claudeCode.test.ts+++ b/packages/heterogeneous-agents/src/adapters/claudeCode.test.ts@@ -2590,6 +2590,51 @@ describe('ClaudeCodeAdapter', () => {).toBeUndefined();});+ /**+ * Real-world regression (recorded on tpc_joZS2mksoY5L): a slow `git commit`+ * (running a lint-staged hook) makes CC track the Bash call as a task and+ * emit `task_started` + `task_notification` back-to-back, with NO out-of-band+ * callback turn in between, immediately followed by the tool_result. That is+ * an inline synchronous tool, not a Monitor-style long-running task β the next+ * turn is the normal main-chain continuation and must NOT be tagged+ * `task-completion` (doing so mis-anchors it and drops it from the rendered+ * chain).+ */+ it('does NOT tag the next turn when a task started and ended with no callbacks (inline tool)', () => {+ const adapter = new ClaudeCodeAdapter();+ init(adapter);++ // A Bash `git commit` tool_use.+ adapter.adapt({+ message: {+ content: [+ {+ id: 'toolu_commit',+ input: { command: 'git commit' },+ name: 'Bash',+ type: 'tool_use',+ },+ ],+ id: 'msg_01',+ },+ type: 'assistant',+ });++ // CC tracks the slow commit as a task, then notifies completion+ // back-to-back β NO callback turn opened while it was alive.+ adapter.adapt(ccTaskStarted('task_1', 'toolu_commit'));+ adapter.adapt(ccTaskNotification('task_1'));++ // The commit's tool_result is consumed inline by the next turn.+ adapter.adapt(ccUser('toolu_commit', 'committed'));++ // Next turn is plain continuation β must carry NO externalSignal.+ const next = adapter.adapt(ccMessageStart('msg_02'));+ expect(+ next.find((e) => e.type === 'stream_start' && e.data?.newStep)!.data.externalSignal,+ ).toBeUndefined();+ });+it('clears unconsumed task-completion lineage on `result`', () => {const adapter = new ClaudeCodeAdapter();init(adapter);@@ -2604,13 +2649,18 @@ describe('ClaudeCodeAdapter', () => {adapter.adapt(ccTaskStarted('task_1', 'toolu_mon'));adapter.adapt(ccUser('toolu_mon', 'Monitor started'));adapter.adapt(ccMessageStart('msg_02'));+ // A signal callback fires while the task is alive (callbackCount > 0), so+ // `task_notification` genuinely arms pendingTaskCompletion β otherwise (an+ // inline tool with no callbacks) nothing is armed and this test would pass+ // vacuously, no longer guarding the `result` clear path.+ adapter.adapt(ccMessageStart('msg_03'));adapter.adapt(ccTaskNotification('task_1'));// Run ends before the summary turn fires (unusual but possible).adapter.adapt({ result: 'ok', type: 'result', usage: undefined });// A later turn (e.g. follow-up user message) must NOT inherit- // the unconsumed task-completion lineage.- const next = adapter.adapt(ccMessageStart('msg_03'));+ // the unconsumed task-completion lineage β `result` dropped it.+ const next = adapter.adapt(ccMessageStart('msg_04'));expect(next.find((e) => e.type === 'stream_start' && e.data?.newStep)!.data.externalSignal,).toBeUndefined();diff --git a/packages/heterogeneous-agents/src/adapters/claudeCode.ts b/packages/heterogeneous-agents/src/adapters/claudeCode.tsindex 2b91eb7c2ef..b10780cffd5 100644--- a/packages/heterogeneous-agents/src/adapters/claudeCode.ts+++ b/packages/heterogeneous-agents/src/adapters/claudeCode.ts@@ -672,8 +672,19 @@ export class ClaudeCodeAdapter implements AgentEventAdapter {// task-ended notification) can be tagged with `task-completion`.// Last-task-wins if multiple tasks end before a summary fires β in// practice CC summarizes once per LLM call.+ //+ // Gate on `callbackCount > 0`: only a task that actually fired out-of-band+ // callback turns while alive is a genuine long-running task whose ending+ // produces a post-task summary (the summary "keeps it inside the same+ // AssistantGroup as the preceding callbacks" β so there must BE preceding+ // callbacks). A task that fires `task_started` and `task_notification`+ // back-to-back with no intervening callback turn was an inline synchronous+ // tool that CC merely tracked as a task (e.g. a slow `git commit` running a+ // lint-staged hook); its `tool_result` is consumed by the next turn in the+ // normal main chain. Tagging that turn `task-completion` mis-anchors it and+ // drops it from the rendered chain β so leave it untagged.const ending = this.activeTasks.get(raw.task_id);- if (ending) {+ if (ending && ending.callbackCount > 0) {this.pendingTaskCompletion = {sourceToolCallId: ending.toolUseId,sourceToolName: ending.sourceToolName,