feat(04-03): add adaptive timeout to Orchestrator

- Add _is_long_command method to detect long-running commands
- Update handle_message to use adaptive timeout based on command type
- Long commands (execute-phase, plan-phase, etc.) use timeout=None
- Regular commands use DEFAULT_TIMEOUT (60 seconds)
- Add TestAdaptiveTimeout test class with 6 test cases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-11 19:01:08 +08:00
parent b817b457e9
commit 774e450ee3
2 changed files with 173 additions and 2 deletions
+16 -2
View File
@@ -83,6 +83,17 @@ class Orchestrator:
self.user_context_managers[user_id] = UserContextManager(user_id, self._users_root)
return self.user_context_managers[user_id]
def _is_long_command(self, command: str) -> bool:
"""Check if command requires no timeout.
Args:
command: The command name (e.g., 'execute-phase', 'status').
Returns:
True if command is in LONG_COMMANDS, False otherwise.
"""
return command in self.LONG_COMMANDS
def _handle_new_project(self, user_id: str, project_name: str) -> Dict[str, Any]:
"""Handle /gsd:new-project command.
@@ -273,8 +284,11 @@ class Orchestrator:
if args:
full_command = f"{full_command} {args}"
# Execute command
result = self.executor.execute(session, full_command)
# Determine timeout based on command type
timeout = None if self._is_long_command(command) else self.executor.DEFAULT_TIMEOUT
# Execute command with adaptive timeout
result = self.executor.execute(session, full_command, timeout=timeout)
# Truncate output if needed
output = result.output