Visitar URL original
Run the Agent Setup Past a Failed Tool Upgrade, and Skip a Held cswap by ptr727 · Pull Request #4116 · ptr727/ProjectTemplate · GitHub
Skip to content

Run the Agent Setup Past a Failed Tool Upgrade, and Skip a Held cswap - #4116

Merged
ptr727 merged 4 commits into
developfrom
fix/agent-setup-tolerate-tool-failure
Nov 12, 2026
Merged

ptr727 merged 4 commits into
developfrom
fix/agent-setup-tolerate-tool-failure

Conversation

@ptr727

@ptr727 ptr727 commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

On Windows, menu option 11, "Update agent setup" (bootstrap.ps1 -AgentSetup), upgraded the agent CLIs and then stopped. The skills, the Claude Code safety kit and the Codex and opencode rules steps never ran.

Root cause

  • The tool that failed was cswap, not herdr. Nothing was wrong with herdr: its updater printed "already up to date" on stderr and exited 0.
  • Why cswap failed: uv tool upgrade claude-swap upgraded the package in the tool's venv and refreshed the claude-swap.exe launcher. It could not replace cswap.exe, because a running cswap held that file, and Windows lets nothing replace a running executable. uv therefore exited non-zero.
  • How that stopped the setup: install-agents.ps1 recorded Failed: cswap and exited 1. The loader's Invoke-Tool then called die. bootstrap.sh's agent_setup has the same abort through set -e.
  • Why the summary missed the upgrade: the failure path returns before a version change is recorded. So Changed: left out a cswap that had in fact moved to the new version.

Changes

  • Both loaders tolerate a tool failure, and only that.
    • install-agents now exits 3 when a tool failed or was refused while the others still ran. It exits 1 when the run itself refused or stopped, for example a declined prompt, no terminal without --yes, or a usage error.
    • On exit 3, bootstrap.ps1 (Invoke-AgentSetup) and bootstrap.sh (agent_setup) still run the skills, kit and rules steps. Then they print Not current: agent tools (an upgrade failed, see above) on stdout and exit 1.
    • Any other non-zero code stops the setup as before. A failure in the skills, kit or rules step also keeps its current behavior.
  • Both install-agents scripts re-read the version after a failed upgrade. A partial upgrade now still appears under Changed:. One shared helper, record_change / Add-VersionChange, replaces the duplicated inline blocks in the self-updater and manager paths.
  • install-agents.ps1 skips cswap, with a reason, while a running process holds either cswap launcher. This works like the herdr pane case and runs under -DryRun too. Linux needs no equivalent, since a running binary can be replaced there.
  • Docs and the update-host skill now describe the new outcome.
    • The steps in docs/host-setup.md "Agent Setup" and both cswap explanations.
    • The kept-tree paragraph in host-setup/README.md, which now names the install-tools step.
    • update-host's "What the Setup Does" and "Report It", with the generated copies regenerated by build_dist.py.

Tests

  • tests/test_bootstrap.py, for both loaders:
    • An agent setup whose tools step exits 3 still runs every later step, prints the not-current line, and exits 1.
    • One whose tools step exits any other code stops there.
    • The stubs now take a FAIL_CODE.
  • tests/test_install_agents.py:
    • A failed upgrade that moved the version is still listed under Changed:. This is tested for both scripts.
    • cswap is skipped while a copied-bash process stands in for a running launcher, and a dry run previews that skip.
    • A helper-level test of Get-CswapLauncherHolder against a stubbed Get-Process, which runs natively on Windows.
    • The tool-failure assertions move from exit 1 to exit 3.

Run on this host:

  • Native Windows: test_bootstrap.py: 190 ran, OK. test_install_agents.py: OK, its Windows helpers included.
  • WSL Ubuntu: the Linux classes of both files pass, apart from 5 failures that the unmodified main worktree shows identically under WSL.
    • 4 are mise cases in test_install_agents.py.
    • 1 is test_every_managed_tool_is_executable, because /mnt/c has no exec bits.
  • mcr.microsoft.com/powershell container with Python 3.13 via uv: TestInstallAgentsWindows, 46 ran, OK.
  • Docker lint wrapper: shellcheck, shfmt and PSScriptAnalyzer pass. ruff, build_dist.py --check and the prose gate are clean too.

Native verification on Windows 11

These ran from this branch's worktree at 3c1543f, with bootstrap.ps1 -AgentSetup -FromTree <worktree> -Yes, then -AgentStatus -FromTree <worktree>. Host-specific values are replaced with placeholders.

Setup, exit 0:

cswap: at <version>, and a running cswap (process <pid>) holds its launcher, which uv cannot replace while it runs, close it and run this again to update it
  settings -> %USERPROFILE%\.claude\settings.json (autoMode.environment: $defaults added first, so Claude Code's built-in rules apply alongside this host's <n> entries)
  <host> | Windows 11 | hub 3c1543f | payload c0aad5827a70061e | agent-safety v1, fleet-bootstrap v1 | <time>

The $defaults line comes from the first run on this branch, which made the change. Later runs read already current. After that run, autoMode.environment[0] reads $defaults, and every other entry kept its original order, which was compared against a capture taken before the run.

Status, exit 0:

This checkout: payload c0aad5827a70061e, hub 3c1543f
This machine:  <host> | Windows 11 | hub 3c1543f | payload c0aad5827a70061e | agent-safety v1, fleet-bootstrap v1 | <time>
autoMode.environment: <n> untagged entries, with $defaults
CURRENT: this machine matches this checkout.
  codex: CURRENT %USERPROFILE%\.codex\AGENTS.md (config directory present, no codex CLI on PATH)
  opencode: CURRENT %USERPROFILE%\.config\opencode\AGENTS.md
  Not current: fleet skills
  Agent tools: listed above, versions not compared with upstream

Not current: fleet skills is expected here and is not caused by this change. A -FromTree run deliberately leaves the existing skills registration on the bootstrap's kept tree, which still holds the last main install, instead of moving it to a worktree. So the status reads that copy as behind this checkout, and "Every other agent setup step reports current" is not printed. The next -AgentSetup from main after promotion refreshes the kept tree.

The tolerated-failure path did not fire natively, because no tool failed on this host once cswap was skipped. The PowerShell handoff tests cover it natively instead.

Local review

Three local-strict-review passes ran at the frontier tier and were recorded with local_review.py.

  • Round 1 raised 3 findings, all introduced, all fixed in 3c1543f:
    • The loaders treated a decline or refusal as an upgrade failure.
    • The cswap skip did not run under -DryRun.
    • update-host did not report a tool failure or skip.
  • Round 2, over the full diff at 3c1543f, raised none.
  • Round 3, over the full diff at 096d4a8 after the Copilot fixes, raised none.

🤖 Generated with Claude Code

ptr727 and others added 3 commits November 12, 2026 14:19
Option 11 on Windows upgraded the agent CLIs and then stopped, so the
skills, the Claude Code safety kit and the host-wide rules never ran.
uv upgraded cswap's package but could not replace a launcher a running
cswap held, exited non-zero, and install-agents exited 1. The loaders
abort on any non-zero tool exit, bootstrap.ps1 through Invoke-Tool's die
and bootstrap.sh through set -e.

- Both loaders tolerate the agent tools step, run the later steps, then
  print "Not current: agent tools (an upgrade failed, see above)" and
  exit 1, so the failure is never silent.
- Both install-agents scripts re-read the version after a failed
  upgrade, so a partial upgrade still appears under "Changed:".
- install-agents.ps1 skips cswap with a reason while a running cswap
  holds one of its launchers, as the herdr pane case does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The agent setup steps now say a failed tool upgrade does not stop the
later steps and still fails the run. Both cswap explanations say the
upgrade skips cswap while one runs. The kept-tree paragraph names the
install-tools step, since a failed agent tools step no longer stops the
run before the swap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…te-host

The local review found three defects in the previous commits.

- The loaders tolerated any non-zero exit from install-agents, so a
  declined prompt or a refusal ran the later steps and reported an
  upgrade failure that never happened. install-agents now exits 3 where
  a tool failed while the others still ran, and 1 where it refused or
  stopped. The loaders tolerate 3 alone, and every other code still
  stops the setup.
- The held-cswap skip did not run under a dry run, so the preview
  claimed an upgrade the real run would skip. The check only reads the
  process list, so it now runs in both.
- update-host told the agent to report only what the status run names,
  which never carries a tool failure or skip. It now names each tool the
  setup reported as failed or skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings November 12, 2026 22:37
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Linux and Windows tool installers now report partial upgrade failures with exit code 3 and record version changes after failed commands. Host setup treats that code separately, completes later setup steps, then reports the tools as not current and fails.

Changes: Agent Tool Setup

Layer / File(s) Summary
Installer failure and version reporting
host-setup/linux/install-agents.sh, host-setup/windows/install-agents.ps1, host-setup/windows/README.md, docs/host-setup.md, tests/test_install_agents.py
The installers record version changes after failed upgrade commands and return exit code 3 for recorded tool failures. The Windows installer skips a cswap update when its launcher is running. Tests cover these outcomes.
Setup continuation and status reporting
host-setup/bootstrap.sh, host-setup/bootstrap.ps1, tests/test_bootstrap.py, .agents/skills/update-host/SKILL.md, docs/host-setup.md, host-setup/README.md
Setup continues through skills, the safety kit, and global rules after the tools step returns 3. It then reports the tools as not current and returns a failure. Documentation describes the behavior and reporting requirements.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Merge Risk: Minimal · up to 3c154

Setup now continues past a failed tool upgrade and then reports the tools as not current and exits non-zero. Other failures still stop setup. No merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names two real changes in the PR: agent setup continues past a failed tool upgrade (exit code 3), and cswap is skipped when a running process holds its launcher. Both appear in the raw summa…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names two real changes in the PR: agent setup continues past a failed tool upgrade (exit code 3), and cswap is skipped when a running process holds its launcher. Both appear in the raw summary and objectives. The title is long and joins two topics, but it is related to the changeset and does not describe anything absent from it.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 326bb1c and 3c1543f.

Files ignored due to path filters: 3

  • .claude-plugin/fleet-skills/.source-digests/update-host is excluded by !.claude-plugin/fleet-skills/**
  • .claude-plugin/fleet-skills/skills/update-host/SKILL.md is excluded by !.claude-plugin/fleet-skills/**
  • .github/skills/update-host/SKILL.md is excluded by !.github/skills/**
Files selected for processing: 10

  • .agents/skills/update-host/SKILL.md
  • docs/host-setup.md
  • host-setup/README.md
  • host-setup/bootstrap.ps1
  • host-setup/bootstrap.sh
  • host-setup/linux/install-agents.sh
  • host-setup/windows/README.md
  • host-setup/windows/install-agents.ps1
  • tests/test_bootstrap.py
  • tests/test_install_agents.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@ptr727

ptr727 commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 3c1543f279381f936bfc550a9ca37216c77d6358, the content this pull request carries at that commit against develop, and it recorded 0 findings.

Copilot AI 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.

🟡 Changes recommended

The unconditional failure mapping changes deliberate installer refusals from exit 1 to 3, and the dry-run cswap guard lacks regression coverage.

2 open issues
What changed in this PR

This pull request makes agent setup continue after failed tool upgrades while preserving a non-zero overall result, records partial upgrades, and skips Windows cswap launchers held by running processes.

Changes:

  • Continues skills, safety-kit, and rules setup after tolerated tool failures while distinguishing failures from refusals.
  • Rechecks versions after unsuccessful upgrades and reports partial changes.
  • Adds Windows cswap launcher detection, expands cross-platform tests, and updates documentation and generated skill copies.

Review notes: Windows refusal paths currently return exit code 3 instead of the documented 1, and the Windows cswap skip behavior lacks direct -DryRun coverage.

File Description
tests/​test_install_agents.py Tests partial upgrade reporting, failure exit codes, Windows cswap detection, and launcher skipping.
tests/​test_bootstrap.py Tests continued setup after tolerated tool failures and stopping after other failures for both loaders.
host-setup/​windows/​README.md Documents the Windows cswap launcher skip behavior.
host-setup/​windows/​install-agents.ps1 Adds partial-change recording, running-launcher detection, and tolerated tool-failure handling.
host-setup/​README.md Clarifies kept-tree behavior when the install-tools setup step fails.
host-setup/​linux/​install-agents.sh Adds shared version-change recording and exit code 3 for failed upgrades.
host-setup/​bootstrap.sh Continues agent setup after exit code 3 while preserving other failure behavior.
host-setup/​bootstrap.ps1 Adds equivalent Windows continuation and final failure reporting.
docs/​host-setup.md Documents failed-upgrade continuation and Windows cswap behavior.
.github/​skills/​update-host/​SKILL.md Updates the generated host-update guidance for GitHub tooling.
.claude-plugin/​fleet-skills/​skills/​update-host/​SKILL.md Updates the generated host-update guidance for Claude tooling.
.claude-plugin/​fleet-skills/​.source-digests/​update-host Updates the generated source digest for the host-update skill.
.agents/​skills/​update-host/​SKILL.md Updates the canonical host-update procedure and reporting guidance.

Review effort: Lite

Comment thread host-setup/windows/install-agents.ps1 Resolved
Comment thread host-setup/windows/install-agents.ps1 Resolved
@ptr727

ptr727 commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

A tool install refused per tool, such as codex or opencode on Windows,
exits 3 like any tool that failed while the others still ran. The usage
text claimed every refusal exits 1, so it now says exit 1 is the run
itself refusing or stopping. No caller tolerates such a refusal, since
only the agent setup tolerates 3 and it runs the upgrade alone.

A dry run with a running cswap is now tested to skip it rather than
preview a uv upgrade the real run would not make. Both held-launcher
tests share one helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727

ptr727 commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 096d4a811a857b696ae4aed054988d7360f37c1c, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.58%. Comparing base (326bb1c) to head (096d4a8).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4116   +/-   ##
========================================
  Coverage    76.58%   76.58%           
========================================
  Files           40       40           
  Lines        14136    14136           
========================================
  Hits         10826    10826           
  Misses        3310     3310           
Flag Coverage Δ
python-3.13 76.58% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727
ptr727 merged commit f5194ae into develop Nov 12, 2026
13 checks passed
@ptr727
ptr727 deleted the fix/agent-setup-tolerate-tool-failure branch November 12, 2026 23:13
ptr727 added a commit that referenced this pull request Nov 13, 2026
## Summary

Promotes the .NET SDK line work and two changes from other hub sessions
from `develop` to `main`.

- #4110:
- The Linux host installer's default dotnet set is the fleet's SDK line
plus the newest line the feed carries, so a host whose feed has moved
past 10.0 still builds fleet .NET repositories.
- Each installer names the line itself (`DOTNET_FLEET_LINE` on Linux,
`$DOTNET_MAJOR` on Windows) so it still runs fetched on its own, and a
test holds both to the `global.json` baseline.
- The hub's setup-dotnet steps go through a new
`.github/actions/dotnet-sdk`, which installs the line the caller's
`global.json` selects. It falls back to `10.x` for a caller carrying no
`sdk.version` yet.
- #4127: the shared SDK step's ordering comment states the required
order plainly, answering a Copilot finding on this promotion.
- #4129: the `dotnet-sdk` action reads `global.json` as the dotnet host
and setup-dotnet do, so a commented file selects its line, answering a
Copilot finding on this promotion.
- #4130: a `global.json` whose `sdk` is null gets the fallback line, as
the dotnet host treats it, answering a Copilot thread on this promotion.
- #4116: the agent setup runs past a failed tool upgrade, and a held
`cswap` is skipped.
- #4125: `carry.py` carries a registry entry not yet promoted to `main`
when run from a `develop` checkout.

Closes #4106
Closes #4107

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants