Skip to content

t1524: Fix aidevops update to detect and deploy stale agents#4001

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/stale-agent-detection
Mar 9, 2026
Merged

t1524: Fix aidevops update to detect and deploy stale agents#4001
marcusquinn merged 1 commit intomainfrom
bugfix/stale-agent-detection

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Mar 9, 2026

Summary

  • cmd_update() in aidevops.sh: Moved success message from before setup.sh to after deployment verification. Captures setup.sh exit code and compares repo VERSION with deployed ~/.aidevops/agents/VERSION. Warns user with manual recovery instructions if agents are stale.
  • cmd_check() in auto-update-helper.sh ("up to date" path): After confirming repo=remote, now checks deployed agent VERSION. If stale, re-runs setup.sh --non-interactive and verifies the result — self-heals the permanent mismatch the poller previously couldn't detect.
  • cmd_check() normal update path: After setup.sh succeeds, verifies deployed agents actually match the new version. Logs agents_stale state if mismatch detected instead of falsely reporting success.

Closes #3980

Summary by CodeRabbit

  • Bug Fixes
    • Improved deployment validation to ensure agents are properly deployed after updates.
    • Added verification checks and clearer status reporting if deployment is incomplete, with guidance for resolution.

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
@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Mar 9, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a30b3b85-ccfc-4d12-aaad-227d198183c1

📥 Commits

Reviewing files that changed from the base of the PR and between 4c89f7a and cbd36d9.

📒 Files selected for processing (2)
  • .agents/scripts/auto-update-helper.sh
  • aidevops.sh

Walkthrough

The 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

Cohort / File(s) Summary
Update Flow Verification
aidevops.sh
Captures setup.sh exit code during update and compares repo VERSION with deployed agents VERSION; warns user if deployment fails or versions diverge post-setup.
Auto-Update Stale Detection
.agents/scripts/auto-update-helper.sh
Validates deployed agent version in cmd_check when local and remote versions are equal; triggers non-interactive re-deploy if detected as stale; replaces unconditional success logging with conditional validation in post-update path.

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
Loading
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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • #358: Detects VERSION mismatch between repo and deployed agents, triggering conditional redeploy—core control flow alignment with this PR.
  • #955: Updates auto-update-helper.sh and setup.sh deployment validation logic that this PR refines in the post-update path.
  • #248: Modifies agent version-check flow and deployed VERSION file reading patterns that inform version comparison logic here.

Suggested labels

bug

Poem

🤖 When CLI climbs high but agents lag behind,
Stale versions lurk where false success we find,
Now checks run deep post-setup's careful dance,
Deployed and repo sync in full sync's glance,
No phantom updates, just truth's bright light!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main objective: detecting and deploying stale agents in the aidevops update process.
Linked Issues check ✅ Passed All three core objectives from #3980 are implemented: cmd_update() now verifies deployment post-setup.sh [cmd_update], cmd_check() detects stale agents when repo is current [cmd_check], and deployment validation is added to normal update path [cmd_check].
Out of Scope Changes check ✅ Passed All changes are within scope: modifications to aidevops.sh and auto-update-helper.sh directly address the three identified gaps in issue #3980.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/stale-agent-detection

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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

  • aidevops.sh update command: Refactored the cmd_update() function to defer the success message until after agent deployment verification, capture setup.sh exit codes, and compare the repository version with the deployed agent version, providing warnings and manual recovery instructions for stale agents.
  • auto-update-helper.sh cmd_check() (up-to-date path): Enhanced the cmd_check() function to detect and automatically re-deploy stale agents, even when the repository is already up-to-date, by comparing the current repository version with the deployed agent version and re-running setup.sh if a mismatch is found.
  • auto-update-helper.sh cmd_check() (normal update path): Modified the cmd_check() function to verify that agents are correctly deployed to the new version after setup.sh completes, logging an agents_stale state if a deployment mismatch is detected instead of falsely reporting success.
Changelog
  • .agents/scripts/auto-update-helper.sh
    • Implemented a check for stale deployed agents even when the repository is up-to-date, triggering a re-deployment via setup.sh if a mismatch is found.
    • Added post-setup.sh verification to confirm that agents were successfully deployed to the new version, logging a warning and agents_stale state if deployment is incomplete.
  • aidevops.sh
    • Moved the update success message to occur only after successful agent deployment verification.
    • Captured the exit code of setup.sh and added logic to compare the repository version with the deployed agent version, providing warnings and manual recovery instructions if agents are not correctly deployed.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 393 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Mon Mar 9 19:42:00 UTC 2026: Code review monitoring started
Mon Mar 9 19:42:00 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 393

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 393
  • VULNERABILITIES: 0

Generated on: Mon Mar 9 19:42:03 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

@marcusquinn marcusquinn merged commit a505196 into main Mar 9, 2026
27 checks passed
@marcusquinn marcusquinn deleted the bugfix/stale-agent-detection branch March 9, 2026 19:52
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +755 to +768
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

Choose a reason for hiding this comment

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

high

This block has a logic flaw and a redundant variable.

  1. Logic Flaw: If setup.sh fails (setup_exit != 0), but the deployed version happens to match the repo version, the else block is executed, incorrectly printing a "success" message. A failed setup should never result in a success message.
  2. Redundant Variable: repo_version is redundant. The new_version variable, defined on line 722, already holds the same value.

I suggest refactoring this block to fix the logic and remove the redundancy.

Suggested change
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

Comment on lines +910 to +911
local deployed_version
deployed_version=$(cat "$HOME/.aidevops/agents/VERSION" 2>/dev/null || echo "none")

Choose a reason for hiding this comment

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

medium

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
  1. In shell scripts, extract repeated logic into an internal helper function to improve maintainability. This applies even for standalone scripts where external source dependencies are avoided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t1524: aidevops update deploys CLI but not agents — stale agent detection gap

1 participant