Skip to content

fix(core,harness): separate subagent waits from ordinary tool timeouts - #3879

Merged
Buktal merged 1 commit into
agentscope-ai:mainfrom
Buktal:codex/fix-subagent-timeout
Oct 31, 2026
Merged

Buktal merged 1 commit into
agentscope-ai:mainfrom
Buktal:codex/fix-subagent-timeout

Conversation

@Buktal

@Buktal Buktal commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

AgentScope-Java Version

2.1.0-SNAPSHOT; based on upstream main at e190a8d1b.

Description

A synchronous agent_spawn or agent_send can be cancelled by the ordinary-tool timeout before its own wait finishes. Raising the application override alone also leaves it silently capped at 600 seconds.

Fixes #3878.

Summary

- Ordinary-tool timeout wraps the entire subagent invocation
+ Delegation uses AgentSpawnTool's existing wait timer
+ Positive application force-sync overrides can exceed 600 seconds

Add an opt-in timeoutManaged tool flag, defaulting to false, and enable it on agent_spawn / agent_send. Ordinary tools, including tools called inside the child, retain their configured timeout. The LLM-facing 600-second cap and parent-cancellation propagation are preserved. Update the existing English and Chinese subagent guides.

Related: #3166 and #1451. This PR focuses on spawn/send and does not change task_output or add a separate application-ceiling policy. It overlaps #2749 in AgentSpawnTool and the subagent guides; it does not depend on that PR.

Evidence

  • Before: Tool execution failed: Tool execution timeout after PT10M interrupts the whole delegation; an application override of 1800 is also clamped to 600.
  • After: regression coverage uses a 50 ms ordinary-tool timeout and a 200 ms child invocation. Both spawn and send finish successfully through direct and batch Toolkit calls. Ordinary-tool timeout, parent cancellation, and the child's own force-sync timeout remain covered.

Validation completed on Windows with Java 21:

mvn -B -T1C clean verify                                         PASS
mvn -B -T1C -pl agentscope-harness -am \
  -Dtest=AgentSpawnTool*Test,ToolExecutorTest,ReflectiveFunctionToolTest test
                                                               66 tests passed
npm test                                                       13 tests passed
npm run validate                                               PASS

npm run broken-links reports 2,222 broken links across 328 files. This patch changes no links or anchors; the repository's documentation source check and strict build validation pass.

Merge Danger

Door: Two-way; revert the commit to restore the previous timeout behavior.

Blast Radius: Tools. The new flag defaults to false; only the two delegation tools opt in. Applications own the positive force-sync wait budget.

Checklist

  • Code formatted with mvn spotless:apply
  • All tests pass in the full clean verify
  • Javadoc comments updated
  • Related English and Chinese documentation updated
  • Code ready for review

@mintlify

mintlify Bot commented Oct 31, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 4cb703a.

Approve preview

@Buktal
Buktal merged commit ac59f61 into agentscope-ai:main Oct 31, 2026
7 checks passed
chickenlj added a commit that referenced this pull request Nov 13, 2026
xzxiaoshan pushed a commit that referenced this pull request Nov 20, 2026
#4278)

## Summary

- Mark `task_output` and `wait_async_results` as `timeoutManaged`.
- Keep each tool's existing self-bounded wait budget authoritative,
instead of allowing the ordinary tool execution timeout to interrupt the
wait first.
- Add focused regression coverage for a short Toolkit-level timeout that
must not cut short a longer managed wait.
- Update the English and Chinese subagent documentation.

Fixes #1451.

## Background

`task_output(block=true)` accepts a wait timeout up to 600 seconds,
while the default ordinary tool timeout is 5 minutes. As a result, a
valid `task_output` wait could be interrupted by the outer
`ExecutionConfig.TOOL_DEFAULTS` timeout before its own deadline.

`agent_spawn` and `agent_send` already use the existing `timeoutManaged`
mechanism introduced by #3879. This change applies the same semantics to
the two SubAgent result-waiting tools:

- `task_output(block=true)` owns its bounded wait timeout.
- `wait_async_results` owns its existing 60-second default / 120-second
maximum wait budget.

`wait_async_results` is not affected by the default 5-minute ordinary
timeout, but a shorter application-configured tool timeout can currently
interrupt its own bounded wait. Marking it as timeout-managed makes the
behavior consistent.

## Behavior

- `task_output(block=true)` continues to use its existing timeout
parameter, default, and 600-second cap.
- `wait_async_results` continues to use its existing timeout parameter,
default, 120-second cap, and consecutive-empty-wait guardrails.
- Non-blocking operations such as `task_output(block=false)`,
`task_cancel`, and `task_list` are unchanged.
- Ordinary tools continue to use the normal `ExecutionConfig` timeout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Ordinary tool timeout cancels synchronous Harness subagents before their configured deadline

2 participants