Skip to content

Commit a62cdeb

Browse files
fix(agentex): publish task_updated when a task is failed via the service
AgentTaskService.fail_task persisted FAILED via task_repository.update without publishing a task_updated event — the only terminal write that didn't emit. An actively streaming viewer therefore never learned the task failed and its SSE stream blocked forever (an eventless terminal transition). Route fail_task through update_task so it emits like every other terminal write. Now all terminal transitions publish an event, which the SSE in-loop check reacts to — no eventless-terminal leak. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 79b341a commit a62cdeb

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

agentex/src/domain/services/task_service.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ async def forward_task_to_acp(
166166
async def fail_task(self, task: TaskEntity, reason: str) -> None:
167167
task.status = TaskStatus.FAILED
168168
task.status_reason = reason
169-
await self.task_repository.update(task)
169+
# Publish task_updated so streaming viewers see the failure and end.
170+
# Every terminal write must emit; SSE termination relies on it.
171+
await self.update_task(task)
170172

171173
async def get_task(
172174
self,
@@ -374,7 +376,11 @@ async def cancel_task(
374376
new_status=TaskStatus.CANCELED,
375377
status_reason="Task canceled by user",
376378
)
377-
return updated if updated is not None else await self.task_repository.get(id=task.id)
379+
return (
380+
updated
381+
if updated is not None
382+
else await self.task_repository.get(id=task.id)
383+
)
378384

379385
async def interrupt_task(
380386
self, agent: AgentEntity, task: TaskEntity, acp_url: str

0 commit comments

Comments
 (0)