Add stop hook for pre-commit, pytest, and CI validation#1878
Draft
Add stop hook for pre-commit, pytest, and CI validation#1878
Conversation
This PR adds a project-level stop hook that validates code quality and CI status before allowing the agent to finish: Features: - Runs pre-commit run --all-files to check formatting/linting - Detects changed files and runs pytest for appropriate packages - Checks GitHub CI status for pushed commits - Waits up to 5 minutes for in-progress CI runs - Blocks agent from stopping if any checks fail - Provides detailed feedback via JSON output with failure reasons Hook files: - .openhands/hooks.json - Hook configuration for stop event - .openhands/hooks/on_stop.sh - Shell script with validation logic Co-authored-by: openhands <[email protected]>
Collaborator
Author
|
@OpenHands /codereview-roasted and tell me if the project hook is supported in OpenHands/OpenHands-CLI and OpenHands/OpenHands |
|
I'm on it! xingyaoww can track my progress at all-hands.dev |
SummaryI performed a roasted code review of PR #1878 "Add stop hook for pre-commit, pytest, and CI validation" and investigated project hook support across OpenHands repositories. Code Review (Linus Torvalds Style)🔴 Taste Rating: Needs Improvement Critical Issues:
Improvement Opportunities:
Project Hook Support Status
Bottom line: The No code changes were made - this was a review-only request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a project-level stop hook that validates code quality and CI status before allowing the agent to finish. The hook runs automatically when the agent attempts to stop/finish and can block the stop if any checks fail, providing detailed feedback to the agent about what went wrong.
Features
1. Pre-commit Validation
pre-commit run --all-filesto check formatting, linting, type checking2. Smart Test Running
git status --porcelainopenhands-sdk/*→tests/sdk/openhands-tools/*→tests/tools/openhands-workspace/*→tests/workspace/openhands-agent-server/*→tests/agent_server/3. GitHub CI Status Checking
ghCLI (with fallback to curl API) to check CI status4. Blocking with Feedback
{ "decision": "deny", "reason": "Checks failed", "additionalContext": "## CI Failed\n\nThe following CI checks failed:\n- build-and-evaluate: failure\n..." }additionalContextfieldFiles Added
.openhands/hooks.json- Hook configuration for the stop event.openhands/hooks/on_stop.sh- Shell script with validation logicChecklist
tests/sdk/hooks/) validates the hook loading mechanism.HookConfig.load(working_dir='.')@xingyaoww can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:cf0c6c7-pythonRun
All tags pushed for this build
About Multi-Architecture Support
cf0c6c7-python) is a multi-arch manifest supporting both amd64 and arm64cf0c6c7-python-amd64) are also available if needed