Skip to content

Commit 88d0272

Browse files
fix: add timeout to prompt step subprocess execution
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.
1 parent 42c7230 commit 88d0272

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎src/specify_cli/workflows/steps/prompt/__init__.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,14 @@ def _try_dispatch(
172172
project_root = (
173173
Path(context.project_root) if context.project_root else Path.cwd()
174174
)
175+
timeout = config.get("timeout", 300)
175176

176177
try:
177178
result = subprocess.run(
178179
exec_args,
179180
text=True,
180181
cwd=str(project_root),
182+
timeout=timeout,
181183
)
182184
return {
183185
"exit_code": result.returncode,
@@ -190,6 +192,12 @@ def _try_dispatch(
190192
"stdout": "",
191193
"stderr": "Interrupted by user",
192194
}
195+
except subprocess.TimeoutExpired:
196+
return {
197+
"exit_code": -1,
198+
"stdout": "",
199+
"stderr": f"Prompt timed out after {timeout} seconds.",
200+
}
193201
except OSError:
194202
return None
195203

0 commit comments

Comments
 (0)