Skip to content

fix(code): clarify project hooks trust prompt and stop prompting for user hooks - #5426

Merged
Mason Daugherty (mdrxy) merged 8 commits into
mainfrom
mdrxy/code/hooks-trust-prompt-copy
Aug 11, 2026
Merged

fix(code): clarify project hooks trust prompt and stop prompting for user hooks#5426
Mason Daugherty (mdrxy) merged 8 commits into
mainfrom
mdrxy/code/hooks-trust-prompt-copy

Conversation

@mdrxy

@mdrxy Mason Daugherty (mdrxy) commented Aug 11, 2026

Copy link
Copy Markdown
Member

The project hooks trust prompt now states what is actually being trusted, and no longer offers the user's own hooks file as if a project had shipped it.

Prompt copy

Project hooks can run arbitrary shell commands on your machine.
Hooks file: /path/to/project/.deepagents/hooks.json
Only trust projects you control. Allow once runs this file as it is now;
always allow trusts "/path/to/project" for future sessions and future edits.

The old copy said hooks "can execute commands from " and named neither the scope nor the directory the grant attaches to. The distinction matters: allow once fingerprints hooks.json (edits invalidate the grant); only always allow survives edits and later sessions. HookTrustScreen (shown on cwd switch) carries the same wording.

User hooks are no longer promptable as project hooks

Launching from ~ with no enclosing Git repo made the project hooks path identical to the user hooks path (~/.deepagents/hooks.json), so the prompt asked the user to grant project trust to their own config — and granting it subjected that file to the project-hook gate. The trust check now returns an ungranted policy when the two paths coincide.

Non-Git workspaces otherwise keep working: the hooks loader resolves a non-repo directory as its own project root, so gating on a Git root would have silently stopped loading hooks that still get read.

Path escaping

Prompt paths are interpolated into Rich markup; a directory named proj[bold]x would render as projx. Paths are now escaped.

…roject root

The prompt asked to "Always allow hooks in this workspace" without ever
saying what a workspace is. It now names the exact directory being
trusted, warns that hooks run arbitrary shell commands and that future
edits are covered, and offers "Always allow hooks in this repo".

Also stop prompting when the launch directory has no git root. The
user_cwd fallback treated any such directory (e.g. ~) as a project root,
so the user hooks file at ~/.deepagents/hooks.json was presented as
project-scoped — and "Allow once" there would execute user hooks under
the project label.
@github-actions github-actions Bot added dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: S 50-199 LOC labels Aug 11, 2026

@open-swe open-swe Bot 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.

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment thread libs/code/deepagents_code/main.py Outdated
Rich markup in filesystem paths (e.g. a repo named [repo]) was being
consumed by Console.print, so the prompt did not reliably show the exact
directory being trusted. Escape config_path and project_root with
rich.markup.escape.
The prompt fires for any workspace, not just Git repositories, so "repo"
named a precondition the gate does not require. Use "project", matching
the "Project hooks" framing the prompt already leads with.

Mirror the wording into the in-session cwd-switch prompt, which presents
the same decision and still carried the older copy.

Cover the path escaping: Rich consumes `[bold]` as a style tag, so an
unescaped project path renders with the segment silently dropped in the
prompt the trust decision rests on.
@mdrxy Mason Daugherty (mdrxy) changed the title fix(code): clarify project hooks trust prompt and skip it without a project root fix(code): clarify project hooks trust prompt and stop prompting for user hooks Aug 11, 2026

@open-swe open-swe Bot 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.

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment thread libs/code/deepagents_code/tui/widgets/cwd_switch.py Outdated
Allow once installs a content-bound session grant: `with_session_grant`
fingerprints hooks.json, and `allows` re-reads the file, so an edit
invalidates the grant and the edited hooks stop running. Only the
persisted store is keyed by root alone, so only always allow carries
across edits and later sessions.

The warning sat above both choices and claimed future edits were covered
either way, overstating what allow once grants at the moment the user
picks between them.
@mdrxy
Mason Daugherty (mdrxy) merged commit 61d3279 into main Aug 11, 2026
57 checks passed
@mdrxy
Mason Daugherty (mdrxy) deleted the mdrxy/code/hooks-trust-prompt-copy branch August 11, 2026 22:11
Mason Daugherty (mdrxy) pushed a commit that referenced this pull request Aug 12, 2026
> [!CAUTION]
> Merging this PR will automatically publish to **PyPI** and create a
**GitHub release**.

For the full release process, see
[`.github/RELEASING.md`](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md).

---

_Release notes preview: keep this section in sync with the package
`CHANGELOG.md`. Publish reads the merged CHANGELOG via `release.yml`,
not this PR description — keep them aligned anyway so the PR stays an
accurate historical record for reviewers and anyone returning later._

---


##
[0.1.55](deepagents-code==0.1.54...deepagents-code==0.1.55)
(2026-08-12)

### Features

- Added a `/context` usage report for inspecting context consumption
([#5407](#5407)).
- Added a cache and context status row for at-a-glance session state
([#5408](#5408)).
- Added configurable warnings when a session exceeds the configured cost
threshold
([#5405](#5405)).
- Added support for persisting and reconfiguring ACP sessions
([#5366](#5366)).
- Added automatic updates for installed plugins
([#5368](#5368)).
- Added a toggle for diff line numbers
([#5427](#5427)).
- `Ctrl+S` in `/auto model` now stores `[models].auto_classifier`
([#5313](#5313)).

### Fixes

- Restored edit diffs in resumed threads
([#5391](#5391)).
- Added a resume hint after crashes
([#5412](#5412)).
- Clarified the project hooks trust prompt and stopped prompting for
user hooks
([#5426](#5426)).
- Cleared dynamic subagents on the next turn
([#5437](#5437)).
- Improved grouped tool summaries by counting distinct targets
([#5409](#5409)).
- Improved ask-user choice wrapping and selection styling
([#5442](#5442)).
- Serialized `dcode` self-upgrades across processes
([#5252](#5252)).
- Added warnings for stale dependencies in editable installs
([#5386](#5386)).
- Hid incomplete extras from version output
([#5352](#5352)).
- Removed the optional-provider startup tip
([#5421](#5421)).
- Removed the “Message restored to input” toast
([#5253](#5253)).

_End release notes preview._

---

> [!NOTE]
> A **New Contributors** section is appended to the GitHub release notes
automatically at publish time (see [Release
Pipeline](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md#release-pipeline),
step 2).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: langchain-oss-automated-triage[bot] <248757908+langchain-oss-automated-triage[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: S 50-199 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant