Flip status to ``failed``, record error, schedule eviction.
(
task_id: str,
*,
error: str,
registry: "RuntimeTaskRegistry",
)
| 292 | |
| 293 | |
| 294 | def fail_agent_task( |
| 295 | task_id: str, |
| 296 | *, |
| 297 | error: str, |
| 298 | registry: "RuntimeTaskRegistry", |
| 299 | ) -> None: |
| 300 | """Flip status to ``failed``, record error, schedule eviction.""" |
| 301 | def _fail(prev: TaskStateBase) -> TaskStateBase: |
| 302 | if not isinstance(prev, LocalAgentTaskState): |
| 303 | return prev |
| 304 | if is_terminal_task_status(prev.status): |
| 305 | return prev |
| 306 | # Mirror error into result_text so TaskOutput callers reading |
| 307 | # the final text still see something useful (TS does this). |
| 308 | return _terminal_replace( |
| 309 | prev, |
| 310 | status="failed", |
| 311 | error=error, |
| 312 | result_text=prev.result_text or error, |
| 313 | ) |
| 314 | |
| 315 | registry.update(task_id, _fail) |
| 316 | |
| 317 | |
| 318 | def kill_async_agent( |