Repository navigation
fix(agent-ui): Agent panel, approval and run history fixes (bug-crawl batch F1) - #751
Merged
Merged
Conversation
…it it The Agent's Git tools work in a history of their own (.cortex-agent-git) so the source project's metadata is never touched. That history was created at the first Git call, from the files as they were then: an edit made before any Git call became part of the baseline, so git_status and git_diff showed nothing, and the requested commit was empty (it was forced with --allow-empty), while the only commit holding the change was the synthetic "Work-copy baseline". WorkCopy.create now commits the copy's starting contents as that baseline, before the model runs, in a fresh bare repository with system and global configuration disabled, so no project hook, filter or attribute driver can run (the hostile-driver security test covers it). The Git tools adopt that baseline, refuse to rebuild one from edited files if it goes missing, and record commits with normal non-empty semantics. A tool used without a WorkCopy keeps the old first-use initialisation. Fixes #582 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
grep decided between "search this file" and "search this folder" by the path's name: anything that passed the file-name check was treated as a file. A folder called src.py or lib.ts passes that check, was then refused as "not a regular file", and was never searched. grep now asks what the path is in the work copy, without following links: a real directory is walked, anything else goes through the single-file checks, which still refuse links and non-regular files. Fixes #581 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Creating a work copy read the whole project under the source-file and byte limits and applied the .gitignore rules only afterwards. A small project with an ignored generated folder of a few thousand tiny files hit the 2,048-file limit, and no Agent run could start on it. The walk now prunes ignored paths as it reaches them: a directory's .gitignore is read when the walk first reaches something in it, and an ignored folder is never entered, so its files count against nothing. Git's rule that a file inside an ignored folder cannot be re-included is kept. The scanned-entry limit still counts every entry read. Fixes #608 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oint remains Accepting an Agent run's changes leaves an undo checkpoint. Preparing a new checkpoint refused any existing one for the same project, so after the first accepted run every later accept on that project failed with recovery_required, and no Agent action could keep the earlier edits and release the checkpoint; only undoing them could. Only an unfinished write batch (a checkpoint still pending) now blocks a new accept. A finished checkpoint is just an undo point, and several can coexist safely: undo refuses (stale_source) when a file no longer has the content its accept left, so undoing an earlier run after a later one changed the same file never overwrites the later change. Fixes #580 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An Agent work copy lives only while its run object does. Shutdown closed the shells but kept the copies, and a new process starts with no run objects, so nothing could discard them: the private copies, with their unaccepted files, and the linked Git worktrees registered in the project stayed on disk for good. When the run ledger opens (once per process, before any run of that process exists) every copy still on disk is removed the way an explicit discard removes it: no link is followed, and a linked worktree is removed from the project it was made from (or pruned there if removal fails). Accepted changes are unaffected; they are in the project and their undo points are kept. Best effort: a copy that cannot be removed is tried again at the next start. Fixes #607 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The file tools wrote files up to 1 MiB, but the work copy's snapshot reads files only up to 256 KiB: a larger file was written and reported as success, then left out of the changeset as if nothing had changed. And one diff over the 60,000-character review limit failed the whole changeset, so no change in the run could be reviewed or accepted. The file tools now refuse, before writing, a file larger than the snapshot reads (reading still accepts up to 1 MiB). A change whose diff is over the review limit is shown as a notice naming its size, the other changes stay reviewable, and accepting the oversized one is refused (diff_too_large) since nobody could see it. Fixes #583 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The final answer had the verification report appended ("Check results:
...") and the whole string was then cut to 16,000 characters when it was
published. A long answer lost its test and check results entirely, with
nothing to say it had been cut, although the run was marked completed.
The model's text is now what gets cut, with a notice, so the answer plus
its whole check report fits the output limit; the publisher uses the
same limit.
Fixes #610
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The update_plan tool stored the model's plan (items and statuses) with its step, but step events, live and replayed, carried only the generic summary "Plan updated (3 items)". The client had no way to show the plan the model was keeping for the user. Step events are now built in one place for both paths, and a plan step also carries "plan": its items and statuses, re-validated with the plan tool's own rules. The event payload is untyped in the contract, so no contract change is needed; the Agent page renders it in a separate change. Refs #584 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A run_checks call names a check by index, and the checks are detected again when it runs. After the user approved the command shown (say, npm run lint), a manifest changed before resume could put a different command at that index, and the approved call ran it (npm run test) without anyone having reviewed it. The check tool now remembers which check and command each pending approval was asked for, by tool-call ID. When the approved call runs, a different check at that index is refused (checks_changed) and nothing runs; a new request then puts the current command up for review. Fixes #589 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A sandboxed process's output was buffered in a deque limited to 256 chunks. The total is already bounded by MAX_OUTPUT_BYTES, which stops the process tree when exceeded, so the count limit bounded nothing: it silently dropped the oldest chunks when output came in many small reads. A caller that reads after the process exits, as the Git tool does, lost the beginning of the output and reported it as complete. The buffer is no longer limited by count; the byte cap still bounds it. Fixes #609 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ight The Agent loop gave each model request the run's Stop event only, and looked at the wall-clock budget once the request had returned. One slow or stalled reply held the Agent worker, and the one active-run slot, for the transport's ten-minute read timeout, long past the default two-minute budget. A transport cut short this way could also be reported as a model error. Each model request now gets an event that Stop or the run's deadline sets, so the transport is interrupted on time, and an exception after an interruption is reported with the interruption's reason (wall_clock_budget or cancelled). Fixes #605 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Before a model's first Agent run, a short capability probe sends a few synthetic requests. They went out with no cancellation event, so the client took its blocking path, and Stop was looked at only between whole checks: a stalled probe request held the run, and the one Agent slot, until the transport's long read timeout, and up to three more requests could follow a Stop. The probe now sends every request through a wrapper that carries the run's Stop event, so a request in flight is interrupted, and starts no request once Stop was asked for; the stop is never swallowed as a failed check. The test that expected the first check to finish its two exchanges after Stop now expects none after it. Fixes #606 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While a run's live object exists, its events keep their original ids. Once it is gone (discarded, or after a restart) the history is rebuilt from the stored steps and numbered afresh from 1. A client resuming its stream holds a cursor from the live numbering, which can be past every rebuilt id: everything was filtered out, the final status included, and the reconnect ended as an empty, successful stream. In rebuilt history the terminal status now always gets an id past the client's cursor. It is idempotent, and it is what ends the stream. Fixes #592 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stopping a workspace check returned at once when the runner process itself had exited. A child it had started that kept the output pipe open then held the check reading output, and the workspace lock with it, past the check's time limit and past Stop: only closing the check's job (Windows) or killing its process group reaches that child. The check's job or process group is now ended whether or not the runner still runs, and a check counts as running for Stop until check() lets go of it. Fixes #590 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check() looked the session up, then took its lock. A revoke landing in between removed the session and returned; the check then took the detached session's lock, checked only the project root, cleared the cancellation signal and launched a process for a workspace whose access had just been withdrawn. Once it holds the session lock, the check now confirms the session is still registered; revoke removes it under that same lock, so after revoke returns no check can launch. A Stop or revoke that arrives while a check is starting stops it as soon as it has launched instead of being cleared away. Fixes #591 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An Agent run's recovery checkpoint belonged to the bearer session that accepted it, and only that session's Undo could reach it. Once the session ended, nothing could restore or discard the record, yet it kept counting against the shared journal's limits, so later accepts failed with checkpoint_limit for good. Listing the Saved recovery checkpoints panel now hands checkpoints of sessions that have ended to the installation owner. The panel shows their metadata only and offers its usual separately confirmed restore and discard; restore goes through the Agent's own undo rules. Runs, goals and steps stay with the ended session. Fixes #575 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Recording an approval decision moves the run to running, but nothing runs it until a separate Resume request. Stop in that gap only raised a flag no worker would look at, so the run stayed running for good and kept the one Agent slot: every later start was refused as busy. Stop now ends such a run as cancelled at once, releases the slot and closes its shell; the approved call never executes. A driving worker is still stopped cooperatively. The once-approved test that resumed after Stop to reach the cancelled state now expects Stop alone to end the run. Fixes #576 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The work-copy sweep on ledger open (#607) removes copies no run of the new service instance can reach. The restart test still asserted that the parked run's copy was intact; it now asserts the copy is gone, which also leaves the stale approval nothing to write to. Refs #607 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Start trimmed the folder path before sending it, while the consent named the path as entered. Where a trailing space is significant, the run could copy a different directory from the one approved. The path is now sent exactly as entered. Fixes #684 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cloud consent was one boolean, cleared only when the user picked another model. A catalog refresh that removed the chosen model switched the run to another provider with the warning still checked, so Start sent project context to a provider the user had not approved. Consent now records the model it was given for and counts only while that model is selected. Fixes #679 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The backend asks approval for one exact URL, but the card showed only the tool name and the generic "Runs as you" badge: the destination and the fact that the request uses the internet were hidden. The URL now appears in the summary and the details, the card shows the network badge, and a web fetch with no URL is not offered for approval at all. Fixes #675 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The review selected every change and let any selection be confirmed, but one accept takes at most 32 files: a larger changeset failed after the confirmation with a message that did not mention the limit. The review now says how many files are selected and the maximum, disables Accept over it, and the API facade's refusal names the limit. Fixes #681 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #681 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ted run The changes panel took an empty changeset before Undo to mean the work copy was gone, and after Undo showed only a notice. A fully accepted copy has an empty changeset but still exists, and Undo stages its edits again, so the review and Discard disappeared until the run was reopened. Only a discarded or unreachable copy now ends in the recovery-only view; otherwise the panel re-reads the changeset. Fixes #678 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plan steps now carry the plan's items and statuses (backend half of #584), but the timeline showed only "Plan updated (n items)". A plan step's details now list each item with its status as plain text; a malformed plan shows no plan at all. Fixes #584 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The history row's discard callback was created while run A was shown and compared against that render's run. When its acknowledgement arrived after run B had been opened, it cleared B's timeline, cursor and follower. The hook now compares against the run shown at that moment. Fixes #683 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
History's Delete removed the whole row, though discard removes only the work copy: the run and its undo checkpoint stay. A refresh brought the row back with Delete enabled, and the second discard failed with copy_unavailable. The page also forgot the open run. Runs now report copy_available. History labels the action "Discard work copy", keeps the row after discarding and disables the action once no copy exists. The open run is re-read instead of forgotten, and its changes panel remounts to offer recovery only. Fixes #680 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Recording an approval decision moves a run to running, but only an explicit Resume schedules it. The page kept "Resume needed" in component state set only when Resume failed right after a decision: reopening the run or remounting the page lost it, and a lost decision response never set it, so a run waiting for Resume had no way to continue. Runs now report resume_required, and the page offers Resume when the server says so. A failed decision request re-reads the run instead of guessing; nothing is approved or resumed automatically. Fixes #682 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the stream dropped, the follower asked for the run's status and stopped at once if the run was parked or finished, never replaying what it missed: the approval card or the final answer was lost until the run was reopened (#676). And it stopped for good at waiting_approval, so an approval that expired stayed actionable and kept Start disabled (#677). The follower now replays from its cursor before stopping. If that replay keeps failing for a run known to be parked or finished, it says so after a bounded number of retries. While a run is parked, it checks the run every five seconds, and replays and follows again once it has expired, been decided elsewhere or stopped. Nothing is approved automatically. Fixes #676 Fixes #677 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The run-identity ref was assigned during render, which React's rules (and the lint gate) forbid. start, open and forget already set it as they change the run; an effect keeps it in step otherwise. Refs #683 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…utlive The test published an artifact with a one-second retention and then read it back, expecting it to be there. On a slow CI runner more than a second passed in between and the read failed with "Artifact retention has expired" (PR #749, backend shard 1). The artifact now lives a minute, and the cleanup that must remove it is asked about two minutes ahead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # Change_Log.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Batch F1 of the bug-crawl plan: 12 issues in 14 commits. Each fix commit adds a regression test that was run against the old code and fails there.
Fixes
fix(agent): let Stop end a run parked after an approval decision: Recording an approval decision moves the run to running, but nothing runs it until a separate Resume request. Stop in that gap only raised a flag no worker would look at, so the run stayed running for good and kept the one Agent slot: every later start was refused as busy.fix(agent-ui): send the exact project folder the user approved: Start trimmed the folder path before sending it, while the consent named the path as entered. Where a trailing space is significant, the run could copy a different directory from the one approved. The path is now sent exactly as entered.fix(agent-ui): tie cloud consent to the model it was given for: Cloud consent was one boolean, cleared only when the user picked another model. A catalog refresh that removed the chosen model switched the run to another provider with the warning still checked, so Start sent project context to a provider the user had not approved. Consent now records the model it was given for and counts only while that model is selected.fix(agent-ui): show a web fetch's exact URL before it is approved: The backend asks approval for one exact URL, but the card showed only the tool name and the generic "Runs as you" badge: the destination and the fact that the request uses the internet were hidden. The URL now appears in the summary and the details, the card shows the network badge, and a web fetch with no URL is not offered for approval at all.fix(agent-ui): enforce the 32-file accept limit before confirmation: The review selected every change and let any selection be confirmed, but one accept takes at most 32 files: a larger changeset failed after the confirmation with a message that did not mention the limit. The review now says how many files are selected and the maximum, disables Accept over it, and the API facade's refusal names the limit.test(agent-ui): write the 32-file diffs as escaped single-line strings:fix(agent-ui): re-read the staged changes after undoing a fully accepted run: The changes panel took an empty changeset before Undo to mean the work copy was gone, and after Undo showed only a notice. A fully accepted copy has an empty changeset but still exists, and Undo stages its edits again, so the review and Discard disappeared until the run was reopened. Only a discarded or unreachable copy now ends in the recovery-only view; otherwise the panel re-reads the changeset.fix(agent-ui): show the plan a plan step carries in the timeline: Plan steps now carry the plan's items and statuses (backend half of Agent plan updates are persisted but their items and statuses never reach the live or replayed timeline #584), but the timeline showed only "Plan updated (n items)". A plan step's details now list each item with its status as plain text; a malformed plan shows no plan at all.fix(agent-ui): let a late discard clear only the run it was for: The history row's discard callback was created while run A was shown and compared against that render's run. When its acknowledgement arrived after run B had been opened, it cleared B's timeline, cursor and follower. The hook now compares against the run shown at that moment.fix(agent): keep a run in history after its work copy is discarded: History's Delete removed the whole row, though discard removes only the work copy: the run and its undo checkpoint stay. A refresh brought the row back with Delete enabled, and the second discard failed with copy_unavailable. The page also forgot the open run.fix(agent): keep the Resume action for a run parked after its decision: Recording an approval decision moves a run to running, but only an explicit Resume schedules it. The page kept "Resume needed" in component state set only when Resume failed right after a decision: reopening the run or remounting the page lost it, and a lost decision response never set it, so a run waiting for Resume had no way to continue.fix(agent-ui): replay missed run events and watch a parked run: When the stream dropped, the follower asked for the run's status and stopped at once if the run was parked or finished, never replaying what it missed: the approval card or the final answer was lost until the run was reopened (Agent SSE reconnect stops before replaying missed approval or final output #676). And it stopped for good at waiting_approval, so an approval that expired stayed actionable and kept Start disabled (Expired Agent approvals remain actionable and leave the page stuck in waiting status #677).fix(agent-ui): keep the current-run ref in step outside render: The run-identity ref was assigned during render, which React's rules (and the lint gate) forbid. start, open and forget already set it as they change the run; an effect keeps it in step otherwise.test(execution): give the artifact store test a retention it cannot outlive: The test published an artifact with a one-second retention and then read it back, expecting it to be there. On a slow CI runner more than a second passed in between and the read failed with "Artifact retention has expired" (PR fix(agent): Agent run, event and checkpoint fixes (bug-crawl batch B9) #749, backend shard 1). The artifact now lives a minute, and the cleanup that must remove it is asked about two minutes ahead.Tests
Run locally on Windows, one test file at a time: the test files each commit touches, plus the neighbouring suites for the same area, all passing. CI runs the full Quality gate on this PR, and the serial Python-compatibility suite (3.12-3.14) was run on this branch with workflow_dispatch before merge, since PR CI does not run it.
Risk and rollback
Each fix is its own commit; reverting the PR or one commit restores the previous behaviour. Commit messages give the root cause and the behaviour change of each fix.
The changelog entries are added as the last commit before this PR merges.
Fixes #576
Fixes #684
Fixes #679
Fixes #675
Fixes #681
Fixes #678
Fixes #584
Fixes #683
Fixes #680
Fixes #682
Fixes #676
Fixes #677
The local pre-push hook was skipped with the maintainer's authorization; CI is the gate.
🤖 Generated with Claude Code