fix: fix sub agent timeout

This commit is contained in:
hetaoBackend
2026-02-08 21:09:18 +08:00
parent 542b04588a
commit f01c470e64
3 changed files with 15 additions and 8 deletions

View File

@@ -15,7 +15,7 @@ class SubagentConfig:
disallowed_tools: Optional list of tool names to deny.
model: Model to use - 'inherit' uses parent's model.
max_turns: Maximum number of agent turns before stopping.
timeout_seconds: Maximum execution time in seconds (default: 300 = 5 minutes).
timeout_seconds: Maximum execution time in seconds (default: 900 = 15 minutes).
"""
name: str
@@ -25,4 +25,4 @@ class SubagentConfig:
disallowed_tools: list[str] | None = field(default_factory=lambda: ["task"])
model: str = "inherit"
max_turns: int = 50
timeout_seconds: int = 300
timeout_seconds: int = 900

View File

@@ -29,6 +29,7 @@ class SubagentStatus(Enum):
RUNNING = "running"
COMPLETED = "completed"
FAILED = "failed"
TIMED_OUT = "timed_out"
@dataclass
@@ -332,7 +333,7 @@ class SubagentExecutor:
f"[trace={self.trace_id}] Subagent {self.config.name} execution timed out after {self.config.timeout_seconds}s"
)
with _background_tasks_lock:
_background_tasks[task_id].status = SubagentStatus.FAILED
_background_tasks[task_id].status = SubagentStatus.TIMED_OUT
_background_tasks[task_id].error = f"Execution timed out after {self.config.timeout_seconds} seconds"
_background_tasks[task_id].completed_at = datetime.now()
# Cancel the future (best effort - may not stop the actual execution)