Skip to content

Strengthen guidance for git commands in the terminal tool - #55787

Merged
rtfeldman merged 5 commits into
mainfrom
AI-154/git-no-pager-editor
May 5, 2026
Merged

Strengthen guidance for git commands in the terminal tool#55787
rtfeldman merged 5 commits into
mainfrom
AI-154/git-no-pager-editor

Conversation

@rtfeldman

@rtfeldman rtfeldman commented May 5, 2026

Copy link
Copy Markdown
Contributor

Move guidance about pty-blocking commands from the TerminalToolInput struct-level doc comment to the command field's doc comment so it's surfaced more prominently to the model in the tool's JSON schema, and call out --no-pager and GIT_EDITOR=true explicitly for git operations.

In practice, the previous wording about git --no-pager diff was easy for agents to overlook, leading to terminal calls that block waiting on less (for git log/git diff/git show) or on an interactive editor (for git rebase/git commit/git merge).

Unit eval change before/after wording change:

image

Closes AI-154

Release Notes:

  • Zed Agent's terminal tool now much more consistently uses --no-pager and GIT_EDITOR with git commands

Move guidance about pty-blocking commands from the struct-level doc
comment to the `command` field's doc comment so it's surfaced more
prominently to the model, and call out `--no-pager` and
`GIT_EDITOR=true` explicitly for git operations.
@rtfeldman rtfeldman self-assigned this May 5, 2026
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 5, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label May 5, 2026
rtfeldman added 3 commits May 5, 2026 11:32
Two new evals under `crates/agent/src/tools/evals/terminal_tool.rs`,
gated behind the `unit-eval` feature flag (same as the existing
`edit_file` evals):

* `eval_git_log_uses_no_pager`: prompts the model to show recent
  commits and asserts the resulting terminal command contains
  `git`, `log`, and `--no-pager`.
* `eval_git_rebase_sets_git_editor`: prompts the model to rebase the
  current branch onto `origin/main` and asserts the resulting
  terminal command contains `git`, `rebase`, and `GIT_EDITOR=true`.

Each eval runs 100 iterations and requires a 95% pass rate, matching
the pattern in `edit_file.rs`. The eval harness streams the model
completion, pulls out the first complete `terminal` tool use, parses
it as `TerminalToolInput`, and asserts substrings against the
`command` field.
Move the pty-blocking guidance back to the TerminalToolInput
struct-level doc comment (so it lands in the top-level tool
description rather than buried in a per-field schema entry) and
rewrite it with concrete MUST/NOT examples for both --no-pager
and GIT_EDITOR=true. Also add a shorter REMINDER on the command
field itself.

In a 10-iteration unit-eval, the previous wording produced 0/10
correct invocations on both the git-log and git-rebase prompts;
this wording produces 10/10 on both.

Also add eval_git_rebase_implied_sets_git_editor as a stress test
where 'rebase' is implied (combine 3 commits) but not literally
requested.
Replace the per-eval substring check (`command_contains_all`) with a
single `git_pty_safe` assertion that's intentionally permissive about
which git subcommand the model picks. It only fails if a known
pager-piping subcommand (`log`, `diff`, `show`, `blame`) is missing
`--no-pager` (or `PAGER=cat` / `GIT_PAGER=cat`), or a known
editor-invoking subcommand (`rebase`, `commit`, `merge`, `tag`) is
missing `GIT_EDITOR=true` (or equivalent).

Motivation: on the indirect-rebase prompt the model correctly
investigates the commit history with `git log` first before deciding
how to combine the commits. The previous assertion (which required
`git`, `rebase`, and `GIT_EDITOR=true` substrings) treated this as a
failure even though the model produced a perfectly pty-safe
`git --no-pager log` invocation. The new assertion correctly accepts
either path.
@rtfeldman
rtfeldman marked this pull request as ready for review May 5, 2026 18:03
@rtfeldman
rtfeldman requested a review from benbrandt May 5, 2026 18:03
Satisfy clippy::manual_contains.

@benbrandt benbrandt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@rtfeldman
rtfeldman added this pull request to the merge queue May 5, 2026
Merged via the queue into main with commit c60c0d5 May 5, 2026
31 checks passed
@rtfeldman
rtfeldman deleted the AI-154/git-no-pager-editor branch May 5, 2026 19:59
ebaah46 pushed a commit to ebaah46/zed that referenced this pull request May 6, 2026
…ries#55787)

Move guidance about pty-blocking commands from the `TerminalToolInput`
struct-level doc comment to the `command` field's doc comment so it's
surfaced more prominently to the model in the tool's JSON schema, and
call out `--no-pager` and `GIT_EDITOR=true` explicitly for git
operations.

In practice, the previous wording about `git --no-pager diff` was easy
for agents to overlook, leading to terminal calls that block waiting on
`less` (for `git log`/`git diff`/`git show`) or on an interactive editor
(for `git rebase`/`git commit`/`git merge`).

Unit eval change before/after wording change:

<img width="1662" height="740" alt="image"
src="https://github.com/user-attachments/assets/5f7921f3-87fa-4f88-9839-193ca4522572"
/>

Closes AI-154

Release Notes:

- Zed Agent's terminal tool now much more consistently uses `--no-pager`
and `GIT_EDITOR` with `git` commands
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
…ries#55787)

Move guidance about pty-blocking commands from the `TerminalToolInput`
struct-level doc comment to the `command` field's doc comment so it's
surfaced more prominently to the model in the tool's JSON schema, and
call out `--no-pager` and `GIT_EDITOR=true` explicitly for git
operations.

In practice, the previous wording about `git --no-pager diff` was easy
for agents to overlook, leading to terminal calls that block waiting on
`less` (for `git log`/`git diff`/`git show`) or on an interactive editor
(for `git rebase`/`git commit`/`git merge`).

Unit eval change before/after wording change:

<img width="1662" height="740" alt="image"
src="https://github.com/user-attachments/assets/5f7921f3-87fa-4f88-9839-193ca4522572"
/>

Closes AI-154

Release Notes:

- Zed Agent's terminal tool now much more consistently uses `--no-pager`
and `GIT_EDITOR` with `git` commands
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…ries#55787)

Move guidance about pty-blocking commands from the `TerminalToolInput`
struct-level doc comment to the `command` field's doc comment so it's
surfaced more prominently to the model in the tool's JSON schema, and
call out `--no-pager` and `GIT_EDITOR=true` explicitly for git
operations.

In practice, the previous wording about `git --no-pager diff` was easy
for agents to overlook, leading to terminal calls that block waiting on
`less` (for `git log`/`git diff`/`git show`) or on an interactive editor
(for `git rebase`/`git commit`/`git merge`).

Unit eval change before/after wording change:

<img width="1662" height="740" alt="image"
src="https://github.com/user-attachments/assets/5f7921f3-87fa-4f88-9839-193ca4522572"
/>

Closes AI-154

Release Notes:

- Zed Agent's terminal tool now much more consistently uses `--no-pager`
and `GIT_EDITOR` with `git` commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants