Skip to content

fix: add timeout to prompt step subprocess execution - #3768

Open
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/prompt-step-missing-timeout
Open

fix: add timeout to prompt step subprocess execution#3768
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/prompt-step-missing-timeout

Conversation

@Quratulain-bilal

Copy link
Copy Markdown
Contributor

Summary

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 a 300s timeout.

Changes

  • src/specify_cli/workflows/steps/prompt/init.py: Added timeout parameter (defaulting to 300s, matching shell step) and handle subprocess.TimeoutExpired gracefully.

Testing

All 176 workflow tests pass.

@Quratulain-bilal
Quratulain-bilal requested a review from mnriem as a code owner July 27, 2026 18:55
@mnriem
mnriem requested a review from Copilot July 27, 2026 21:33

@mnriem mnriem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure the default timeout can be overriden

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a 300-second timeout to prompt subprocess execution and handles timeout failures gracefully.

Changes:

  • Passes a timeout to subprocess.run().
  • Converts TimeoutExpired into a failed prompt result.
Show a summary per file
File Description
src/specify_cli/workflows/steps/prompt/__init__.py Adds prompt execution timeout handling; currently references undefined config.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Medium

project_root = (
Path(context.project_root) if context.project_root else Path.cwd()
)
timeout = config.get("timeout", 300)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: config was not in scope inside the @staticmethod _try_dispatch. Now timeout is extracted from config in execute() (which has access to the step config dict) and passed as a parameter to _try_dispatch(timeout=timeout). The default remains 300 seconds. Also added subprocess.TimeoutExpired handling that returns a clean error message.

@mnriem

mnriem commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback and fix test & lint errors

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.
@Quratulain-bilal
Quratulain-bilal force-pushed the fix/prompt-step-missing-timeout branch from 88d0272 to 37277a5 Compare July 27, 2026 22:31
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.

3 participants