DRAFT: For PR #2035: add /hooks endpoint#2088
DRAFT: For PR #2035: add /hooks endpoint#2088enyst wants to merge 8 commits intosupport-openhands-hooks-json-in-agent-serverfrom
Conversation
\nCo-authored-by: openhands <openhands@all-hands.dev>
… flags \nCo-authored-by: openhands <openhands@all-hands.dev>
\nCo-authored-by: openhands <openhands@all-hands.dev>
all-hands-bot
left a comment
There was a problem hiding this comment.
Taste Rating: 🟡 Acceptable
The core design is clean and simple—router delegates to service, service delegates to SDK. Good separation of concerns. However, there are security and testing gaps that need addressing before this is production-ready.
Key Insight: This is a sensible architectural choice (explicit API vs implicit loading), but the implementation needs hardening around path validation and more comprehensive test coverage.
\nCo-authored-by: openhands <openhands@all-hands.dev>
\nCo-authored-by: openhands <openhands@all-hands.dev>
\nCo-authored-by: openhands <openhands@all-hands.dev>
all-hands-bot
left a comment
There was a problem hiding this comment.
🟡 Acceptable - Core logic is sound and well-tested, but has unnecessary complexity and weak validation that should be addressed.
\nCo-authored-by: openhands <openhands@all-hands.dev>
all-hands-bot
left a comment
There was a problem hiding this comment.
Taste Rating: 🟡 Acceptable - Core design is solid and pragmatic, but error handling and path validation need hardening before production use.
[CRITICAL ISSUES]
Path Validation Security: The validation is too permissive and doesn't protect against path traversal or unauthorized access.
Error Handling: Swallowing all exceptions loses critical debugging information when things go wrong.
Test Logic Inconsistency: Test expects rejection of relative paths, but code actually resolves them.
[IMPROVEMENT OPPORTUNITIES]
API Design: Returning None for both "not found" and "invalid path" conflates different failure modes.
Test Coverage: Missing tests for malformed JSON, permission errors, and other failure scenarios.
Unrelated Change: AGENTS.md documentation is useful but unrelated to the hooks feature.
VERDICT: ✅ Worth merging after fixes - The skills-style approach is cleaner than auto-loading. Address the path validation and error handling issues first.
KEY INSIGHT: Good separation of concerns (router/service) and explicit control over loading behavior, but security and observability need attention before this touches production.
…_dir \nCo-authored-by: openhands <openhands@all-hands.dev>
Note on path validation / workspace rootsAI review raised concerns about Current agent-server patterns:
What this PR does now:
Follow-up:
|
Path handling patterns in agent-server (context for /hooks)On the path-safety concern: today agent-server already has multiple endpoints that accept filesystem paths and do not consistently enforce a single workspace-root sandbox policy. The design assumption is that agent-server runs inside the agent-box and client apps (app-server/CLI) provide the right paths + auth, so these are effectively internal APIs within the sandbox boundary. Examples in current codebase:
What we’re doing for /hooks for now:
Follow-up:
|
Hi! I’m OpenHands-GPT-5.2 (an OpenHands dev assistant agent).
This is a stacked PR targeting PR #2035 (base:
support-openhands-hooks-json-in-agent-server) as a friendly alternative proposal.Motivation
Instead of auto-loading
.openhands/hooks.jsoninsideevent_service.start()(agent-server), this proposes a skills-style approach:POST /api/hooksendpoint on agent-serverHookConfiginto the agent payload, and send it viaStartConversationRequest.hook_configload_user=false), and agent-server conversation start stays more deterministicWhat’s included
openhands-agent-server/openhands/agent_server/hooks_router.py: new/hooksendpointopenhands-agent-server/openhands/agent_server/hooks_service.py: loads{project_dir}/.openhands/hooks.jsonopenhands-agent-server/openhands/agent_server/api.py: wires router under/apitests/agent_server/test_hooks_router.pycc @ak684 — thanks! This PR is meant to be a little incremental change rebased on yours so we can compare designs side-by-side.
Co-authored-by: openhands openhands@all-hands.dev
@enyst can click here to continue refining the PR