t1524: Fix aidevops update to detect and deploy stale agents#4001
t1524: Fix aidevops update to detect and deploy stale agents#4001marcusquinn merged 1 commit intomainfrom
Conversation
cmd_update() now verifies deployed agent VERSION matches repo after setup.sh runs, and only prints success after confirmation. If agents are stale, warns user with manual recovery instructions. cmd_check() (auto-update poller) now checks deployed agent VERSION on the 'already up to date' path and re-runs setup.sh if stale. Also verifies deployment after normal updates. Closes #3980
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe changes add deployment verification to both the auto-update helper and main update command to detect and handle stale deployed agents when CLI and repo versions are current but don't match the deployed agent version, preventing false "up to date" reports. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant aidevops.sh
participant setup.sh
participant RepoVER as Repo VERSION
participant DeployedVER as Deployed VERSION
User->>aidevops.sh: aidevops update
aidevops.sh->>aidevops.sh: git pull (repo update)
aidevops.sh->>RepoVER: Read new version
aidevops.sh->>setup.sh: Run --non-interactive
activate setup.sh
setup.sh->>DeployedVER: Deploy agents
setup.sh-->>aidevops.sh: Exit code
deactivate setup.sh
alt Setup succeeded AND versions match
aidevops.sh->>User: ✓ Agents deployed successfully
else Setup failed OR versions differ
aidevops.sh->>User: ⚠ Deployment verification failed
aidevops.sh->>User: Suggest manual setup.sh
end
sequenceDiagram
participant AutoPoller
participant auto-update-helper.sh
participant RepoVER as Repo VERSION
participant GitHub as GitHub API
participant DeployedVER as Deployed VERSION
participant setup.sh
AutoPoller->>auto-update-helper.sh: cmd_check()
auto-update-helper.sh->>RepoVER: Get local version
auto-update-helper.sh->>GitHub: Get remote version
alt Versions equal
auto-update-helper.sh->>DeployedVER: Check deployed agents
alt Deployed version stale
auto-update-helper.sh->>setup.sh: Trigger --non-interactive redeploy
setup.sh->>DeployedVER: Verify post-deploy
auto-update-helper.sh->>AutoPoller: Log deployment update
else Deployed version current
auto-update-helper.sh->>AutoPoller: Log "up to date"
end
else Versions differ
auto-update-helper.sh->>AutoPoller: Trigger update flow
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the reliability of agent updates and deployments by addressing scenarios where setup.sh might fail silently or not fully deploy agents, leading to version mismatches. It introduces robust version checks within both the manual update command and the auto-update helper, enabling detection and self-healing of stale agent installations, ensuring that deployed agents consistently match the intended repository version. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Mon Mar 9 19:42:03 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Code Review
This pull request introduces important checks to detect and fix stale agent deployments, which improves the robustness of the update process. The changes in aidevops.sh and auto-update-helper.sh correctly address the issue of silent deployment failures. I have a couple of suggestions to improve the implementation: one to fix a logic flaw in aidevops.sh that could lead to incorrect success messages, and another to reduce code duplication in auto-update-helper.sh for better maintainability, aligning with best practices for shell scripting.
Note: Security Review did not run due to the size of the PR.
| local repo_version deployed_version | ||
| repo_version=$(cat "$INSTALL_DIR/VERSION" 2>/dev/null || echo "unknown") | ||
| deployed_version=$(cat "$HOME/.aidevops/agents/VERSION" 2>/dev/null || echo "none") | ||
|
|
||
| if [[ "$setup_exit" -ne 0 ]]; then | ||
| print_warning "Setup exited with code $setup_exit" | ||
| fi | ||
|
|
||
| if [[ "$repo_version" != "$deployed_version" ]]; then | ||
| print_warning "Agent deployment incomplete: repo=$repo_version, deployed=$deployed_version" | ||
| print_info "Run 'bash $INSTALL_DIR/setup.sh' manually to deploy agents" | ||
| else | ||
| print_success "Updated to version $new_version (agents deployed)" | ||
| fi |
There was a problem hiding this comment.
This block has a logic flaw and a redundant variable.
- Logic Flaw: If
setup.shfails (setup_exit != 0), but the deployed version happens to match the repo version, theelseblock is executed, incorrectly printing a "success" message. A failed setup should never result in a success message. - Redundant Variable:
repo_versionis redundant. Thenew_versionvariable, defined on line 722, already holds the same value.
I suggest refactoring this block to fix the logic and remove the redundancy.
| local repo_version deployed_version | |
| repo_version=$(cat "$INSTALL_DIR/VERSION" 2>/dev/null || echo "unknown") | |
| deployed_version=$(cat "$HOME/.aidevops/agents/VERSION" 2>/dev/null || echo "none") | |
| if [[ "$setup_exit" -ne 0 ]]; then | |
| print_warning "Setup exited with code $setup_exit" | |
| fi | |
| if [[ "$repo_version" != "$deployed_version" ]]; then | |
| print_warning "Agent deployment incomplete: repo=$repo_version, deployed=$deployed_version" | |
| print_info "Run 'bash $INSTALL_DIR/setup.sh' manually to deploy agents" | |
| else | |
| print_success "Updated to version $new_version (agents deployed)" | |
| fi | |
| local deployed_version | |
| deployed_version=$(cat "$HOME/.aidevops/agents/VERSION" 2>/dev/null || echo "none") | |
| if [[ "$setup_exit" -ne 0 ]] || [[ "$new_version" != "$deployed_version" ]]; then | |
| if [[ "$setup_exit" -ne 0 ]]; then | |
| print_warning "Setup exited with code $setup_exit" | |
| fi | |
| if [[ "$new_version" != "$deployed_version" ]]; then | |
| print_warning "Agent deployment incomplete: repo=$new_version, deployed=$deployed_version" | |
| fi | |
| print_info "Run 'bash $INSTALL_DIR/setup.sh' manually to deploy agents" | |
| else | |
| print_success "Updated to version $new_version (agents deployed)" | |
| fi |
| local deployed_version | ||
| deployed_version=$(cat "$HOME/.aidevops/agents/VERSION" 2>/dev/null || echo "none") |
There was a problem hiding this comment.
The command to get the deployed version, cat "$HOME/.aidevops/agents/VERSION" 2>/dev/null || echo "none", is used three times within the cmd_check function (here, on line 916, and on line 975). To improve maintainability and reduce duplication, consider defining a local helper function at the beginning of cmd_check and using it in all three places.
References
- In shell scripts, extract repeated logic into an internal helper function to improve maintainability. This applies even for standalone scripts where external
sourcedependencies are avoided.



Summary
cmd_update()inaidevops.sh: Moved success message from beforesetup.shto after deployment verification. Capturessetup.shexit code and compares repo VERSION with deployed~/.aidevops/agents/VERSION. Warns user with manual recovery instructions if agents are stale.cmd_check()inauto-update-helper.sh("up to date" path): After confirming repo=remote, now checks deployed agent VERSION. If stale, re-runssetup.sh --non-interactiveand verifies the result — self-heals the permanent mismatch the poller previously couldn't detect.cmd_check()normal update path: Aftersetup.shsucceeds, verifies deployed agents actually match the new version. Logsagents_stalestate if mismatch detected instead of falsely reporting success.Closes #3980
Summary by CodeRabbit