Skip to content

fix(delegate): add timeout to subagent run_conversation() (Closes #13768) - #13797

Closed
ms-alan wants to merge 2 commits into
NousResearch:mainfrom
ms-alan:fix/13768-subagent-timeout
Closed

fix(delegate): add timeout to subagent run_conversation() (Closes #13768)#13797
ms-alan wants to merge 2 commits into
NousResearch:mainfrom
ms-alan:fix/13768-subagent-timeout

Conversation

@ms-alan

@ms-alan ms-alan commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

child.run_conversation() in _run_single_child was a raw blocking call — if the subagent got stuck on a slow API or network issue, the parent agent would hang indefinitely.

Fix: Run run_conversation in a dedicated thread with join(timeout=300). On timeout, call child.interrupt() for graceful shutdown, then set a synthetic timeout result.

Changes

  • tools/delegate_tool.py: Wrap child.run_conversation() in a thread, enforce 300s timeout, interrupt + return error result on timeout

Testing

Simulate a stuck subagent (e.g. mock API delay > timeout) → parent returns error instead of hanging

Closes #13768

pander added 2 commits April 22, 2026 10:58
…Research#13720)

When a long-running task is interrupted, prompt_toolkit flushes stdout.
If stdout is in a broken state (pipe closed, /dev/null), this raises
OSError with errno.EIO. The existing except (KeyError, OSError) block
only handled 'is not registered' / 'Bad file descriptor' strings.

Add errno.EIO check so EIO errors are silently suppressed instead of
crashing the CLI. Import errno at top of cli.py.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/delegate Subagent delegation comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Note: #13770 (merged) already addresses #13768 with hard timeout + stale detection. This PR may be superseded — verify against current main.

@alt-glitch

Copy link
Copy Markdown
Collaborator

May be superseded by #13770 (merged).

@ms-alan

ms-alan commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

Closing — upstream PR #13770 has already merged the fix for #13768

@ms-alan ms-alan closed this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Delegation] Subagent run_conversation() has no timeout — can block indefinitely on slow API/network

2 participants