feat(hooks): implement prompt-based evaluation#4160
Conversation
Co-authored-by: openhands <openhands@all-hands.dev> Signed-off-by: onatozmenn <onatozmen44@gmail.com>
|
Maintainers: this changes LLM-backed hook decision behavior. Please add the |
|
Thank you for the PR! Could you perhaps add some logs from the real-world example run, to a temporary (but committed) |
|
@OpenHands Do an initial /codereview of this PR. Post your feedback directly with gh api and event as you think appropriate. |
|
I'm on it! enyst can track my progress at all-hands.dev |
smolpaws
left a comment
There was a problem hiding this comment.
Initial review complete. I did not find a code-level correctness blocker in the prompt-hook implementation: policy/event separation, explicit fail-open signaling, current-LLM lookup, API routing, isolated metrics, lifecycle behavior, and REST compatibility are all covered coherently.
Local verification on the exact PR head (b4b21c12):
- 185 passed, 66 skipped: hooks + hook REST router + REST breakage checker + example discovery
- 6 passed: OpenAPI discriminator tests
- changed-file pre-commit: Ruff, pycodestyle, Pyright, dependency rules all passed
I’m leaving COMMENT rather than APPROVE because this changes LLM-backed agent policy behavior and still lacks the required evaluation evidence:
integration-testlabel is absent. I attempted to add it, but the current authenticated account lacks label permissions.- The requested live-provider
.pr/run artifact is absent, and this environment has noLLM_API_KEY, so I could not produce honest real-world logs. check-examplesfails only because55_prompt_hooks/main.pyis not yet present on docsmain; OpenHands/docs#639 contains the correct synchronized example block but is still open.
Residual follow-up, not introduced by this PR: hook callbacks are synchronous, so command/agent/prompt hooks can block an arun() event loop while evaluating. Fixing that requires an async hook pipeline rather than a prompt-hook-only patch.
Profile selection is addressed in the inline thread.
This review was created by an AI agent (OpenHands) on behalf of Engel Nyst.
|
Just as a note: we will need also a PR in the docs to document the Hook |
|
Added the live run output in The docs PR is already open at OpenHands/docs#639. |
HUMAN:
I reviewed the implementation and test results. The PR is ready for review.
AGENT:
Why
HookType.PROMPTis already public, but it currently falls open without evaluating anything. This adds the intended single-completion policy check between command hooks and tool-using agent hooks.Summary
HookEventpayload and parses the shared allow/deny result.prompt-hook:<name>metrics.success=Falsewhen the model is unavailable or returns an invalid result.Issue Number
Closes #2755
How to Test
.pr/prompt-hooks-live-run.md.Type
Notes
GitHub Copilot assisted with this PR.
This first version uses the active conversation LLM and the
HookEventpayload only. Per-hook profile overrides and extra conversation or workspace context are left for follow-up;HookType.AGENTremains the option when tools or workspace investigation are needed.