Repository navigation
fix(app-conversations): run primary repository hooks in multi-repository conversations when the agent-server can - #1063
Conversation
…ory conversations when the agent-server can
|
@OpenHands /codereview-roasted Review exactly commit 5d6b47c. If the PR head changes, report that and do not approve another commit. Review only: do not push code, merge, deploy, or change attribution. Check correctness, regression coverage, and whether the PR validation claims match the evidence. Keep code comments short. Post the substantive review and link it in your completion message. End the substantive review with these plain lines (no code fence), choosing one verdict: REVIEWED_HEAD: 5d6b47c Use VERDICT: CHANGES_REQUESTED instead when findings require changes. If unable to review, explain the blocker without an approval verdict. |
|
I'm on it! ak684 can track my progress at all-hands.dev |
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||
ak684
left a comment
There was a problem hiding this comment.
Taste rating: needs improvement
Material finding: hook_project_dir never reaches the agent-server (the PR's core mechanism is a no-op)
- File/line:
openhands/app_server/app_conversation/live_status_app_conversation_service.py:2944-2956(conv_settings = user.conversation_settings.model_copy(update={... **hook_project_dir_setting(hook_config, project_dir)})) and:3003-3004(request = conv_settings.create_request(StartConversationRequest, **create_kwargs)). - Root cause:
hook_project_diris injected by stashing it onConversationSettingsviamodel_copy(update=...). ButConversationSettings.create_request()builds its request through_start_request_kwargs(), which forwards only a fixed allowlist of fields (workspace,conversation_id,initial_message,tool_module_qualnames,agent_definitions,plugins,hook_config,observability_*, ...) and never reads ahook_project_dirattribute.ConversationSettingsdoes not declare ahook_project_dirfield on the SDK head of software-agent-sdk#6306 (settings/model.pyis not touched by that PR); even the extra value stored viamodel_copyis invisible tomodel_dump()and is not forwarded. The request is then serialized withrequest.model_dump()(live_status_app_conversation_service.py:862) before thePOST /api/conversations, so the field never appears on the wire. - Effect: Even after an SDK release containing software-agent-sdk#6306, this PR loads the primary repository hooks in a multi-repository start but never tells the agent-server which directory to run them from. Hooks would run from the workspace parent folder with
OPENHANDS_PROJECT_DIRunset against an expanded agent-server — exactly the wrong-tree bug the PR was written to fix. On the current pin (1.59.0) behavior is unchanged as documented, so only the future path is broken, but that path is the entire point of the change. - Evidence (reproduced in the workspace venv with the pinned SDK):
ConversationSettings.model_copy(update={'hook_project_dir': '/workspace/project/app'})stores the value in__dict__, but a subsequentcreate_request(StartConversationRequest, ...)produces a request whosehook_project_dirattribute is absent, andmodel_dump(keys)shows nohook_project_dirkey. Passinghook_project_dir=as an explicit kwarg tocreate_requestis likewise dropped by_start_request_kwargsunless it is added to the forwarded allowlist. - Smallest correction: add
hook_project_dirto the forwarded set. Two viable paths:- In this repo, pass it as a
create_kwargsentry and add it toConversationSettings._start_request_kwargs(e.g. forwardif 'hook_project_dir' in self.model_fields or getattr(self, 'hook_project_dir', None)), or - In software-agent-sdk#6306, declare
hook_project_dironConversationSettingsso_start_request_kwargsforwards it likehook_config.
Because the SDK PR does not add the field, option 1 here is required regardless; without it the wire payload never carries the key.
- In this repo, pass it as a
Secondary: the new unit tests do not reach the request-building path
tests/unit/app_server/test_additional_repositories.py:859-870verifies only thathook_project_dir_setting()returns the right dict literal. No test exercises_build_start_conversation_request_for_userwith a realStartConversationRequest+hook_config, so the drop atcreate_request/serialization is uncaught. A regression test should assertresult.hook_project_dir == project_dir(and its presence inmodel_dump()) on the built request when loading hooks on a supporting agent-server.
Assessment of PR claims
- The
358 passedunit suite andpre-commitare credible claims (CI on head 5d6b47c is green for Python, lint, and builds). - The "not tested live" caveat is accurate, but it understates the issue: the mechanism is broken, not merely untested. When the pins move past 1.59.0, this change will load hooks without any working directory, which is more harmful than today's skip.
Acceptance-criteria checklist (FDE-240)
- Hooks load for multi-repo starts on a supporting agent-server (loading gate works —
loads_repository_hooks). - The primary folder is actually communicated to the agent-server as
hook_project_dir— fails, field is dropped. - Hooks run from the primary's folder — not achievable given the drop; relative-path hooks would still run from the parent folder.
- Single-repository invariants preserved.
[RISK ASSESSMENT] MEDIUM This is a backend API/request-wiring change. No credentials or security boundaries are touched, and the default (1.59.0) path is a documented no-op, so the blast radius on current production is minimal. The materiality is correctness: the feature the PR exists to deliver silently does nothing once the SDK/agent-server support lands, and the broken state is worse than the status quo it replaces (hooks loaded but run from the wrong directory). The fix is small and localized to the request-forwarding path shown above; no human SME sign-off is required beyond normal review, but the author must prove the field reaches the wire (unit test asserting StartConversationRequest.hook_project_dir and its model_dump, or a live run against a supporting agent-server) before merge. A HIGH rating is not warranted because there is no data loss, privilege escalation, or reachable failure on the current deployment; the risk is deferred to the future pin.
Verdict: changes requested — the PR's central mechanism does not propagate hook_project_dir to the agent-server, so once the SDK support lands it would load hooks without telling the agent-server where to run them. Please (1) forward hook_project_dir through ConversationSettings.create_request() (e.g. add it to _start_request_kwargs), and (2) add a regression test that asserts the built StartConversationRequest carries hook_project_dir (and serializes it) when hooks are loaded.
Improve this review? If feedback seems incorrect or irrelevant, update the repository's
.agents/skills/custom-codereview-guide.md(with the/codereviewtrigger), then re-request review. The reviewer reads the guide from the PR head.Resolve with AI? Install the iterate skill and run
/iterate.Was this review helpful? React with 👍 or 👎.
|
Substantive review posted at #1063 (review) REVIEWED_HEAD: 5d6b47c |
|
Reviewed PR #1063 at commit 5d6b47c. Review posted
REVIEWED_HEAD: 5d6b47c FindingsMaterial (blocking): The PR's core mechanism is a no-op. I reproduced this in the workspace venv against the pinned SDK: after Secondary: the new tests ( PR-validation claims
Also confirmed the reviewed head matches commit 5d6b47c (verified before and after posting). No code was pushed, merged, or modified. |
…ory conversations when the agent-server can
|
@OpenHands /codereview-roasted Review exactly commit 2a10c18. If the PR head changes, report that and do not approve another commit. Review only: do not push code, merge, deploy, or change attribution. Check correctness, regression coverage, and whether the PR validation claims match the evidence. Keep code comments short. Post the substantive review and link it in your completion message. End the substantive review with these plain lines (no code fence), choosing one verdict: REVIEWED_HEAD: 2a10c18 Use VERDICT: CHANGES_REQUESTED instead when findings require changes. If unable to review, explain the blocker without an approval verdict. |
|
Disposition for the review on
|
|
I'm on it! ak684 can track my progress at all-hands.dev |
ak684
left a comment
There was a problem hiding this comment.
Taste rating: good — no material findings.
Reviewed head 2a10c180adca268b4107cdd53ff29d144c66eb54. This addresses the previous review (on 5d6b47c) in full:
- Prior material finding (resolved). The earlier review showed
hook_project_dirnever reachedcreate_request()becauseConversationSettings._start_request_kwargs()forwards a fixed allowlist. software-agent-sdk#6306 (head4011988d) now declareshook_project_dironConversationSettings(runtime field,exclude=Trueas withhook_config) and forwards it in_start_request_kwargs(); this PR keeps themodel_copy(update=...)composition and the new regression test (test_build_request_carries_hook_project_dir_on_a_supporting_agent_server) asserts the field on the builtStartConversationRequestand in itsmodel_dump(), so a drop at serialization is now caught. I verified this empirically by installing the SDK PR head into the venv: the test passes, and reverting to the pinned 1.59.0 it skips with the documented reason. - Correctness by case. Feature detection requires the field on both
ConversationConfigandConversationSettings, andbump-sdk.ymlkeepsopenhands-sdk/openhands-agent-server/openhands-toolsin lockstep, so the installed models are a sound proxy for what the sandbox agent-server understands. Single-repo: hooks continue to load andhook_project_dir = project_direquals the existing working directory, so behavior is unchanged. Multi-repo on an old agent-server: hooks still skipped, field not sent. Multi-repo on a supporting agent-server: hooks load from and run in the primary's folder, withOPENHANDS_PROJECT_DIRpointing there — exactly the intended fix. Thehook_config is Noneguard prevents sending the field when no hooks were loaded. - Claims match evidence. On the pinned SDK I reproduced
358 passed, 1 skippedfor the two named files; with the SDK PR head installed the regression test runs and passes (full-file runs green);pre-commitpasses on the changed files; head CI (22 check runs) is green. The "not tested live" caveat is accurate and the dependency on an unmerged SDK PR is disclosed.
Acceptance-criteria checklist (FDE-240)
- Hooks load again for multi-repo starts on a supporting agent-server.
- The primary's folder reaches the agent-server as
hook_project_dir(asserted on the built request and its serialized dump). - On a supporting server hooks run from the primary's folder (agent-server honors the field per SDK PR 6306).
- Single-repository invariants preserved (
loads_repository_hooks([])isTrueregardless of support).
[RISK ASSESSMENT] LOW–MEDIUM — backend request-wiring change, inert on the current 1.59.0 pin (documented no-op); no security boundary, credential, or data-surface change. hook_project_dir is the same project_dir value already sent to the agent-server's /api/hooks endpoint. Blast radius on current production is nil and the future path has a regression test that fails closed if the forwarding regresses. No human-gate comment warranted.
Key architectural insight: the PR treats "does the sandbox support running hooks from a named directory" as a feature-detectable property of the pinned, lockstep-bumped SDK models rather than a hardcoded version check, so the change is inert until the pin moves and needs no follow-up when SDK/agent-server releases land — provided the lockstep bump discipline holds.
REVIEWED_HEAD: 2a10c18
REVIEW_REQUEST: 0af4e3cf1fc84c718cf3d0816fac6e78
VERDICT: APPROVED
|
Reviewed PR #1063 at commit 2a10c18. Review posted
REVIEWED_HEAD: 2a10c18 |
|
Review complete. Here's the summary. Review OutcomeVerdict: APPROVED — no material findings remain on head What I verified
Where the review landed
The only caveat, which the author already disclosed: the mechanism depends on software-agent-sdk#6306, which is still open/blocked — so the change is inert until that lands and the pin moves. That's expected for this cross-repo fix and is covered by a regression test that fails closed. |
Review posted for
|
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
I found nothing that should block this PR. Reviewed at 2a10c180.
Correctness. I checked each case against the base:
- Pinned 1.59.0:
ConversationConfigandConversationSettingshave nohook_project_dirfield. So hooks are still skipped when there are additional repositories, andhook_project_dir_setting()returns{}. Behaviour is the same asmain. - Single repository: hooks still load. The value sent equals
project_dir, which is already the agent's working directory. - Multi-repository with a supporting SDK: hooks load from the primary's folder. The same folder goes through
ConversationSettings._start_request_kwargs(), which software-agent-sdk#6306 at4011988dnow forwards. The agent-server then stores it and passes it toHookExecutoras both thecwdandOPENHANDS_PROJECT_DIR. - No hooks loaded: the
hook_config is Noneguard keeps the field off the request. - Older agent-server that gets the key:
StartConversationRequestuses pydantic's defaultextra='ignore', so the unknown key cannot cause a 422.
Tests.
- On the locked 1.59.0 SDK, the two touched test files give 358 passed and 1 skipped. The skip is the new regression test.
- With the #6306 head installed for
openhands-sdk,openhands-agent-serverandopenhands-tools, the same files give 359 passed. The regression test runs and confirmshook_project_diris on the builtStartConversationRequestand in itsmodel_dump(). I restored the venv to the lock afterwards. - All head CI checks pass (21 success, 3 skipped).
Non-blocking note, for when the pin moves. agent_server_runs_hooks_from_project_dir() checks the app server's installed SDK, not the sandbox's agent-server. Two kinds of sandbox can run an older agent-server: a custom sandbox spec (see is_custom_sandbox_spec) and a sandbox started before an upgrade. On those, a multi-repository start will load the primary's hooks again. The older server ignores hook_project_dir, so the hooks run from the parent folder, which is the case #1046 skips today. That is a narrow case and the trade-off may be fine, but the claim that "an older agent-server never gets a key it does not know" holds only while the pin is at 1.59.0.
✅ APPROVED
LLM profile: all-hands-bot-reviewer_claude-opus-5-5 · Model: openhands/claude-opus-5-5
|
On hold for now: the author is deciding whether conversation hooks should run in multi-repository conversations at all, and how that should be surfaced to users, before this lands. Approved and green; converting back to draft so it is not merged by accident. No further changes planned until that decision. |
…ory conversations when the agent-server can
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Since my approval of 2a10c180, the PR diff has not changed; it was rebased onto main 807e788b. But main has changed in a way that turns my earlier non-blocking note into a blocking finding.
Blocking: the support check reads the app server's SDK, not the sandbox's agent-server.
agent_server_runs_hooks_from_project_dir()assumes the sandbox agent-server runs the same SDK version as the app server. #1083 (OHE-3838), now on main, makes version skew a supported path._wait_for_sandbox_startreuses running sandboxes through_find_running_sandbox_for_user()or an explicitsandbox_id._ensure_profile_runtimenow lets an older sandbox host new conversations, with a warning.- So once the SDK pin moves past #6306, here is what happens on a multi-repository start in a sandbox created before the upgrade:
- The primary's hooks load.
- The older agent-server ignores
hook_project_dir, becauseStartConversationRequestuses pydantic's defaultextra='ignore'. - The hooks run from the parent folder. That is the case #1046 deliberately skips today.
- The PR notes say no further change is needed when the pin moves, so this would appear silently at that point.
- Suggested fix:
_ensure_profile_runtimealready fetches/server_infobefore the request is built. Gateloads_repository_hooksandhook_project_dir_settingon the sandbox's reportedsdk_version, compared with the first release that contains #6306, as well as on the local model check. Then add a test where the sandbox reports an older version.
Re-verified on 2bac5c36:
- Locked 1.59.0: 392 passed, 1 skipped (the regression test).
- With software-agent-sdk#6306 head
27ed684ainstalled: 393 passed. I restored the venv to the lock afterwards. - Python test and lint checks for this head pass.
🔄 CHANGES REQUESTED
LLM profile: all-hands-bot-reviewer_claude-opus-5-5 · Model: openhands/claude-opus-5-5
…ory conversations when the agent-server can
|
Disposition for the review on Fixed on
|
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Resolved: the finding from my review of 2bac5c36. That review flagged that the gate checked the app server's SDK, not the sandbox's agent-server. This head fixes it, and I resolved the thread.
_ensure_profile_runtimenow returns thesdk_versionit reads from/server_info. That function has one caller, and that caller passes the version to the request builder.agent_server_runs_hooks_from_project_dir(sandbox_sdk_version)now needs both conditions:- the local models have the field;
- the sandbox reports a parsable openhands-sdk version at least as new as the installed one.
- If either fails, the multi-repository hooks are skipped and
hook_project_diris not sent. A missing or unparsable version counts as a failure. - A single-repository start is unchanged.
Tests.
- The new older-sandbox test proves the skip path: no
_load_hooks_from_workspacecall and nohook_project_dir, even when the local models have the field. - Locked 1.59.0: 401 passed, 1 skipped.
- With software-agent-sdk#6306 head
27ed684ainstalled: 402 passed. I restored the venv to the lock afterwards. - All head CI checks pass.
Non-blocking. The gate compares against the installed SDK version, not against the first release that contains #6306. So after every later SDK bump, sandboxes one release behind will skip multi-repository hooks until they are replaced, even though they support the field. That is a safe failure, and the PR notes describe it. Once the release version is known, a fixed minimum version would keep hooks running in those sandboxes.
✅ APPROVED
LLM profile: all-hands-bot-reviewer_claude-opus-5-5 · Model: openhands/claude-opus-5-5
|
🚀 Released in 1.86.0. |
Why
With additional repositories the agent works from the parent folder, so #1046 stopped loading the primary repository's
.openhands/hooks.json: the agent-server ran hook commands from the parent folder, and a relative path in a hook pointed at the wrong tree. software-agent-sdk#6306 lets a conversation name the directory command hooks run from.Summary
hook_project_diron both the start request andConversationSettings(software-agent-sdk#6306) and the sandbox's agent-server reports (/server_info) an openhands-sdk at least as new as the app server's, a start with additional repositories loads the primary repository's hooks again and sets the primary's folder ashook_project_diron the conversation settings, whichcreate_request()forwards to the agent-server, so hooks run there and see it asOPENHANDS_PROJECT_DIR. A single-repository start sends its repository folder, which is where its hooks already ran.sandbox_id, a running sandbox reused for the user, Plan sub-conversations). Its older agent-server ignores the field and would run the hooks from the parent folder, so for it the hooks stay skipped and nothing is sent._ensure_profile_runtimealready reads/server_info; it now returns the reportedsdk_versionbeside the browser availability.Issue Number
FDE-240
How to Test
pytest tests/unit/app_server/test_additional_repositories.py tests/unit/app_server/test_live_status_app_conversation_service.pyon the pinned SDK (1.59.0): 401 passed, 1 skipped. The skipped test is the new request-building regression test, which only runs when the installed SDK has the field. New: the gate's version table (same or newer sandbox passes; older, missing or unparsable version fails; no field locally fails), the real gate against the locked SDK,/server_inforeturning the SDK version, and a start with additional repositories in a sandbox one release behind the app server, which loads no hooks and sends nohook_project_direven though the app server's models have the field.27ed684a, plus the litellm it needs) installed in the venv, on the previous head: 393 passed with the regression test running, asserting that the builtStartConversationRequesthashook_project_dir == <working_dir>/<repo>and thatmodel_dump()carries it. The venv was restored to the locked 1.59.0 afterwards.tests/unit/app_serveras a whole: 2,573 passed on the first head; the current head is the same change on main807e788b, beside theconversation_rootshelpers that landed with feat(app-conversation): read files, diffs, skills and hooks of every repository in a multi-repository conversation #1073.SessionStarthook should run the hook from the primary's folder; the feat(app-conversations): start a conversation with several repositories #1046 live run showed the hook not running, which stays the behaviour until then.Video/Screenshots
Not applicable: API behaviour.
Type
Notes
Takes effect when
openhands-sdkandopenhands-agent-servermove past 1.59.0 to a release that contains software-agent-sdk#6306, and only in sandboxes running that release or newer; sandboxes created before the upgrade keep today's behaviour (hooks skipped beside additional repositories) until they are replaced. No further change is needed here at that point.Enterprise server image for this PR: