Skip to content

Fix eight session-analysis defects in questions, waits, pipelines, git and the command hint - #4226

Merged
bbondy merged 8 commits into
brave:mainfrom
netzenbot:fix-session-analysis-nov14
Nov 15, 2026
Merged

bbondy merged 8 commits into
brave:mainfrom
netzenbot:fix-session-analysis-nov14

Conversation

@netzenbot

@netzenbot netzenbot commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #4164
Closes #4165
Closes #4166
Closes #4167
Closes #4168
Closes #4170
Closes #4171
Closes #4172

User impact: a command typed with words after it (/model gpt-5) now says on screen that it was sent as a prompt, and the planner, shell, git and job tools stop refusing or misreporting five ordinary cases.

Decisions to confirm

  1. A delegate prompt that bypass mode answers still waits behind an open ask_user, idling delegates for 33 minutes #4164: every question the permission mode answers skips the shared confirmer, not only exposing reads. Why: the mode's answer needs no person. To reverse: narrow the check in crates/agent/src/permission_mode.rs.
  2. The planner is never told which front end it runs in, so it guessed the desktop app for a terminal screenshot #4165: the editor is a prompt-only front end with no new session Front variant. One-shot, goal and manifest runs and delegates are not told. To reverse: add the variant and map it.
  3. A pipeline step ended by SIGPIPE behind head is reported as 'It failed: step N was killed' for a complete result #4166: a later step that exited 0 is taken as the step that closed the input. In a | b | head where b fails, a is reported as closed, and kill -13 $$ | true is forgiven. The ! prompt has the same shape and is unchanged. To reverse: tighten exec.rs around line 360.
  4. A fourth wait on one long background job is held as a repeated call and stalls the turn for 23 minutes #4167: a wait without until_exit is exempt from the repeat count even though it can return at once. A held call is refused with nobody asked. To reverse: remove Jobs::is_waited_on_while_running.
  5. git rebase -i is refused even with GIT_SEQUENCE_EDITOR set, and the refusal names no working route #4170: a computed or empty editor value, or a terminal editor such as vim, names no editor and stays refused. The GIT_EDITOR= assignment is always asked about, and an allow rule such as Bash(git *) already covers the -c forms, so no new class of exposure is added.
  6. /model followed by a model name starts a model turn with nothing on screen saying it went to the model #4172: it draws a note instead of opening the picker with the name as the cursor position, because a command that took the name would apply it without the look. The French note is wider, so at 80 columns the left side is cleared while it shows.

The problem

#4164. A delegate's question the mode answers waited behind another run's open question.

#4165. The planner was not told which front end it runs in.

#4166. A pipeline ended early by head printed the right lines and reported a step as failed.

#4167. The third bounded wait on a running job in a row was refused as a repeat.

#4168. A large file's diff got a size-only note.

#4170. A git line that sets its own editor was refused as needing a terminal.

#4171. A dropped tool result's stub did not say the result was gone.

#4172. /model gpt-5 started a model turn with nothing on screen saying so.

Reproduce

#4172:

  1. Start a listener that accepts connections and never replies, and point BRAVE_AI_CHAT_ENDPOINT at it, with HOME and BRAVEBOT_HOME in an empty directory.
  2. Start the terminal client and answer n to the trust prompt.
  3. Type /model gpt-5 and press Enter.

The row under the box now reads, at 120 columns:

> /model gpt-5

  ✺ Planning… (11s)
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│╮ Ask Brave Bot to do anything                                                                                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  context not yet measured  ·  ? for shortcuts  ·  ctrl-x info         Prompt sent; ctrl-c stops it; bare word runs it

and at 80 columns:

> /model gpt-5

  ✳ Grooving… (0s)
╭──────────────────────────────────────────────────────────────────────────────╮
│╮ Ask Brave Bot to do anything                                                │
╰──────────────────────────────────────────────────────────────────────────────╯
  ? for shortcuts              Prompt sent; ctrl-c stops it; bare word runs it

Before the change the hint row was empty. The replay tool reported one sequence it does not model, so the screen may differ slightly from a real terminal, and blank lines are trimmed.

The other seven items

None has a screen, so the tests are the reproduction and fail on the parent commit: cargo test -p bravebot-agent --lib is_waited_on (#4167), cargo test -p bravebot-agent --test turn (#4164, #4166, #4167), cargo test -p bravebot-agent --lib cmdline (#4170), cargo test -p bravebot-agent --lib conversation (#4171) and the read_git tests under crates/agent/src/git (#4168). The #4166 turn tests use yes | head -n 3 and a kill -9 stub, not the seq | sort -rn | head line.

The fix

#4164. A question the mode answers is read through a view that does not take the shared confirmer.

#4165. The system prompt gets one sentence naming the terminal, desktop or editor front end.

#4166. A step ended by SIGPIPE with a later step of the pipeline that exited 0 counts as closed, and as a success.

#4167. A bounded wait on a running job is passed without counting.

#4168. read_git diffs a side up to 4 MiB over the changed lines plus 3 lines of context.

#4170. A git line that names its editor outright is not refused, and the refusal text names the working routes.

#4171. The stub is one fixed sentence.

#4172. A no-argument command typed with words after it draws the note while its turn runs.

Verification

crates/agent is not a crate make check-verus reads (contrib/check-verus.py verifies only crates/core), so Region::of in crates/agent/src/git/diff.rs has no Verus contract. It slices and subtracts on offsets summed from the lengths of lines of two blobs read from the repository. A contract would state, for old and again for new:

  • old_from <= old_head <= old.len() - old_tail <= old_to <= old.len();
  • every one of those bounds is a char boundary of old;
  • skipped is the same count of leading lines on both sides.

The first holds because the tail is counted inside old_rest, so old_head + old_tail <= old.len(), and the context taken back from old_head never exceeds old_head.

Test plan

@netzenbot netzenbot self-assigned this Nov 15, 2026
Comment thread docs/specs/delegation.md Resolved
Comment thread crates/agent/src/git/diff.rs Resolved
…ed confirmer

A delegate's question that the permission mode answers without a person (bypass or accept-edits approvals, plan-mode and read-only refusals) is decided when it is asked and no longer queues behind another run's open question. Confining exposes those answers as Unasked, Lent::confirming records the view when the confirmer is lent, and Borrowed::asked refuses a stopped delegate first, then takes the mode's answer, then takes the lock for a question that reaches a person. The mode is read when the question is decided, so a change while another question is open applies. DELEGATE-16 and DELEGATE-25 say so and cite the new tests.

Closes brave#4164
@netzenbot
netzenbot force-pushed the fix-session-analysis-nov14 branch from 4e47f16 to fca839e Compare November 15, 2026 05:20
A job_output call that names a background job of the turn, carries a wait_seconds the tool accepts and does not kill the job is treated as a different call from the ones around it. The count starts again and the call is never held, asked about or recorded in the trail. The decision reads the planner's own tool name and arguments, through the argument gate, and the driver's own observation that the job process has not exited. It never reads what the job printed. A job_output call with no wait_seconds, with a refused wait_seconds, that kills the job, or that names an ended or unknown job is counted and held as before. Bypass still passes the held-call question on; the change removes the question for bounded waits.

The refusal for a repeated call names the tool and the count and gives a route chosen from the tool name. For job_output it says the end of a background job is reported in a message of its own and that a shell loop that sleeps is not a way to wait. The job_output description says what is and is not held. TURN-9, the website pages and the pinned count of Policy::read_planner_argument sites are updated, and each new test is a verified-by line of TURN-9.

Closes brave#4167
A caller that builds a Task says which front end the person is using: the terminal client, the desktop app, or an editor hosting the session over the Agent Client Protocol. The system prompt then carries one fixed sentence for it, pushed as driver text on the person's side only, so a delegate is not given it. The value is a closed enum the caller supplies, never read from a file, a tool result or the session record, so a session resumed in another front end names the one now in use. A caller that says nothing, as a one-shot, goal or manifest run does, has no sentence. Specs INSTR-9 and acp.md and the website instructions page state it.

Closes brave#4165
A step of a pipeline that SIGPIPE ended because a later step of the same pipeline closed its input and exited 0, as `yes | head -n 3` does, is recorded as closed by the next step. The run counts as having succeeded, the ending sentence says it exited 0 and which step stopped because the next step closed its input, and no confinement sentence follows. Any other signal, and SIGPIPE with no later step that exited 0, is still a failed step. Foreground pipelines, substitutions and background jobs share the rule. The decision is read from the exit codes, the signals and the steps places only.

Closes brave#4166
…s what can read a larger one

A diff reads a side up to 4 MiB and compares only the lines between the first line that differs and the last, with three lines of context kept at either end. A one-line change in a file past 1 MiB prints its hunk at the line numbers the file has, in a diff and in the show of a commit. A side past 4 MiB is described by its size.

The notes for a file past the diff cap and past the search cap name read_file on the working copy and run, each only where the turn's list holds it, as the note of a show of a file does. Out::instead holds the wording for all three.

GIT-1, GIT-9, GIT-14, TOOL-6, the known costs in labels.md and the website page describe the new bound and notes.

Closes brave#4168
git rebase -i is no longer refused when the same line assigns GIT_SEQUENCE_EDITOR or GIT_EDITOR to a literal command, or passes -c sequence.editor= or -c core.editor=. GIT_EDITOR and core.editor also let a git commit with no message through. An empty value, a computed value, a value naming a terminal editor, and an assignment in front of another step or another variable name no editor. The subcommand is found past -c and -C options. The refusal of git rebase -i names GIT_SEQUENCE_EDITOR, git rebase --autosquash and git commit --fixup=reword as the routes that work. CMDLINE-15, the run tool reference and the command line overview describe this.

Closes brave#4170
…est and that calling the tool again returns it

The stub that replaces an old tool result said the call ran and its result was shown earlier, so a planner that could not see the text believed it still held it and worked from memory. The stub now says the result is no longer in the request, that calling the tool again returns it (for a read, only the lines needed), and that a call which changes something is not to be repeated. The sentence is the same for every tool and for results sent by id or as prose, and it carries the tool name and size only, as before. COMPACT-18 states the content and lists the tests that pin it, and the sessions page says the same. A read repeated after its result was dropped sends the lines and not the notice that the file has not changed.

Closes brave#4171
A command the table gives no argument, typed with words after it, is a
prompt (CMD-2): `/model gpt-5` opens no picker and `/undo the last
change` undoes nothing. The line is sent at the first Enter, and until
now nothing on the screen said so while the turn ran.

The session marks a turn begun on such a line, from the line the person
typed in the box or from a single queued line, and clears the mark when
any other turn begins. While that turn runs the row under the box says
"Prompt sent; ctrl-c stops it; bare word runs it", at the right like the
leave words' note and no wider than it, so one permission mode name and
the vi mode still fit beside it on eighty columns.

Whether a line qualifies is read off the command table's argument
column by command_table::is_a_command_given_words, so a command added
with no argument is covered without a second list. The bare command, a
command that takes an argument, a longer word such as /models, a prompt
that only mentions a command, a line sent in shell mode and lines sent
together by Ctrl-Enter are not marked.

CMD-2 and CMD-17 state the behaviour and list the tests that pin it,
the command reference and interactive-mode pages say it, and the note
is in the en-US and fr catalogs.

Closes brave#4172
@netzenbot
netzenbot force-pushed the fix-session-analysis-nov14 branch from fca839e to b73f687 Compare November 15, 2026 05:48
@bbondy
bbondy added this pull request to the merge queue Nov 15, 2026
Merged via the queue into brave:main with commit 52f8621 Nov 15, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment