mirror of
https://github.com/github/spec-kit.git
synced 2026-08-03 06:26:30 +08:00
fix: add timeout to prompt step subprocess execution (#3768)
The prompt step subprocess.run() had no timeout, allowing a hung LLM invocation to block the entire workflow engine indefinitely. The shell step already defaults to 300s timeout. Add timeout parameter (defaulting to 300s, matching shell step) and handle subprocess.TimeoutExpired gracefully.
This commit is contained in:
@@ -89,8 +89,9 @@ class PromptStep(StepBase):
|
||||
)
|
||||
|
||||
# Attempt CLI dispatch
|
||||
timeout = config.get("timeout", 300)
|
||||
dispatch_result = self._try_dispatch(
|
||||
prompt, integration, model, context
|
||||
prompt, integration, model, context, timeout=timeout
|
||||
)
|
||||
|
||||
output: dict[str, Any] = {
|
||||
@@ -136,6 +137,7 @@ class PromptStep(StepBase):
|
||||
integration_key: str | None,
|
||||
model: str | None,
|
||||
context: StepContext,
|
||||
timeout: int = 300,
|
||||
) -> dict[str, Any] | None:
|
||||
"""Dispatch *prompt* directly through the integration CLI."""
|
||||
if not integration_key or not isinstance(integration_key, str) or not prompt:
|
||||
@@ -178,6 +180,7 @@ class PromptStep(StepBase):
|
||||
exec_args,
|
||||
text=True,
|
||||
cwd=str(project_root),
|
||||
timeout=timeout,
|
||||
)
|
||||
return {
|
||||
"exit_code": result.returncode,
|
||||
@@ -190,6 +193,12 @@ class PromptStep(StepBase):
|
||||
"stdout": "",
|
||||
"stderr": "Interrupted by user",
|
||||
}
|
||||
except subprocess.TimeoutExpired:
|
||||
return {
|
||||
"exit_code": -1,
|
||||
"stdout": "",
|
||||
"stderr": f"Prompt timed out after {timeout} seconds.",
|
||||
}
|
||||
except OSError:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user