Skip to content

fix(opencode): exclude loop-state from agent discovery and deployment#110

Merged
marcusquinn merged 1 commit intomainfrom
fix/loop-state-tab-cycle
Jan 17, 2026
Merged

fix(opencode): exclude loop-state from agent discovery and deployment#110
marcusquinn merged 1 commit intomainfrom
fix/loop-state-tab-cycle

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Jan 17, 2026

Summary

  • Fixes 'Loop-State/Quality-Loop.Local' appearing in OpenCode tab cycle
  • Loop state files (.agent/loop-state/*.md) are runtime state, not agents

Changes

  1. setup.sh: Use rsync to exclude loop-state/ from deployment to ~/.aidevops/agents/
  2. generate-opencode-agents.sh: Exclude loop-state/ from subagent discovery with -not -path "*/loop-state/*"
  3. generate-opencode-agents.sh: Remove incorrectly created loop-state agent files on regeneration

Root Cause

When running Ralph/Quality loops locally in the aidevops repo, .agent/loop-state/ directory is created with state files like quality-loop.local.md. These were being:

  1. Deployed to ~/.aidevops/agents/loop-state/ by setup.sh
  2. Discovered as subagents by generate-opencode-agents.sh
  3. Appearing in OpenCode's Tab cycle as agents

Testing

After merging, run ./setup.sh to deploy the fix. The loop-state files will be excluded from deployment and removed from the OpenCode agent directory.

Summary by CodeRabbit

  • Chores
    • Excluded runtime loop-state files from agent deployment and discovery processes to ensure proper isolation of temporary state data.
    • Enhanced setup script with selective file copying for more efficient and cleaner deployments.

✏️ Tip: You can customize this high-level summary in your review settings.

- setup.sh: Use rsync to exclude loop-state/ from deployment to ~/.aidevops/agents/
- generate-opencode-agents.sh: Exclude loop-state/ from subagent discovery
- generate-opencode-agents.sh: Remove incorrectly created loop-state agent files

This fixes 'Loop-State/Quality-Loop.Local' appearing in OpenCode tab cycle.
Loop state files are runtime state, not agents.
@marcusquinn marcusquinn merged commit 5ec5ac2 into main Jan 17, 2026
5 of 8 checks passed
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 17, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

The PR excludes runtime loop-state files from agent discovery and deployment processes. It updates the agent generation script to skip loop-state paths and modifies deployment logic to use rsync-based selective copying with fallback handling.

Changes

Cohort / File(s) Summary
Agent Discovery & Cleaning
.agent/scripts/generate-opencode-agents.sh
Adds explicit removal of loop-state-related files during agent cleaning step; updates subagent discovery loop to skip files under loop-state paths, preventing runtime state from being treated as agent code.
Deployment Logic
setup.sh
Replaces direct recursive copy with rsync-based selective deployment when available, explicitly excluding loop-state/ directory; includes fallback to copy + remove pattern for systems without rsync.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🔄 Loop-state slips away, a ghost in the machine,
While agents march forward, clean and lean,
Rsync filters truth from temporal debris,
Zero debt flows—DevOps poetry! ✨

✨ Finishing touches
  • 📝 Generate docstrings

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 @marcusquinn, 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 resolves an issue where local runtime state files, specifically those within the .agent/loop-state/ directory, were mistakenly identified and treated as agents within the OpenCode system. The changes prevent these state files from being deployed to the agent directory and from being discovered as subagents, thereby cleaning up the OpenCode tab cycle and ensuring only actual agents are listed.

Highlights

  • Issue Resolution: Addresses the problem of 'Loop-State/Quality-Loop.Local' files incorrectly appearing in the OpenCode tab cycle.
  • Exclusion from Deployment: The setup.sh script now uses rsync to prevent loop-state/ directories from being deployed to the ~/.aidevops/agents/ path. A fallback cp and rm method is provided if rsync is unavailable.
  • Exclusion from Agent Discovery: The generate-opencode-agents.sh script has been updated to exclude files within loop-state/ directories from subagent discovery using a -not -path "*/loop-state/*" filter in the find command.
  • Cleanup of Existing State Files: generate-opencode-agents.sh now includes an explicit step to remove specific loop-state markdown files (e.g., ralph-loop.local.md, quality-loop.local.md) from the OpenCode agent directory during regeneration, ensuring old, incorrectly created agent files are cleaned up.
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.

@sonarqubecloud
Copy link

@github-actions
Copy link

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Jan 17 03:05:39 UTC 2026: Code review monitoring started
Sat Jan 17 03:05:40 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 262
Sat Jan 17 03:05:40 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Sat Jan 17 03:05:42 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 262
  • VULNERABILITIES: 0

Generated on: Sat Jan 17 03:06:22 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@augmentcode
Copy link

augmentcode bot commented Jan 17, 2026

🤖 Augment PR Summary

Summary: Prevents local runtime loop-state markdown files from being treated as OpenCode agents and deployed to the user agent directory.

Changes: Excludes .agent/loop-state/ during deployment (setup.sh) and during subagent discovery/regeneration (generate-opencode-agents.sh), including cleanup of previously generated loop-state artifacts.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

fi

if [[ $? -eq 0 ]]; then
print_success "Deployed agents to $target_dir"
Copy link

Choose a reason for hiding this comment

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

In the fallback branch, this if [[ $? -eq 0 ]] will reflect the exit code of the last cleanup command (e.g., rm ... || true), so a failed cp could still result in a reported successful deploy.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

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 correctly addresses the issue of loop-state files being treated as agents by excluding them during deployment and discovery. The changes are logical and well-described. I've identified a potential bug in the setup.sh fallback logic that could mask errors during file copy operations, and a point of improvement in generate-opencode-agents.sh to make the cleanup logic more robust. My review includes suggestions to fix these issues.

Comment on lines +1274 to +1278
else
# Fallback: copy then remove loop-state
cp -R "$source_dir"/* "$target_dir/"
rm -rf "$target_dir/loop-state" 2>/dev/null || true
fi

Choose a reason for hiding this comment

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

high

In the fallback case where rsync is not available, the exit status of the cp command is not correctly propagated. If cp fails, the script will continue as if the deployment was successful because the || true on the rm command masks the error. This could lead to silent failures. You should ensure that a failure in cp is reported by preserving and propagating its exit code.

Suggested change
else
# Fallback: copy then remove loop-state
cp -R "$source_dir"/* "$target_dir/"
rm -rf "$target_dir/loop-state" 2>/dev/null || true
fi
else
# Fallback: copy then remove loop-state
cp -R "$source_dir"/* "$target_dir/"
local cp_status=$?
if [[ $cp_status -eq 0 ]]; then
rm -rf "$target_dir/loop-state" 2>/dev/null || true
fi
(exit $cp_status)
fi

Comment on lines +65 to +69
# Remove loop-state files that were incorrectly created as agents
# These are runtime state files, not agents
for f in ralph-loop.local.md quality-loop.local.md full-loop.local.md loop-state.md re-anchor.md postflight-loop.md; do
rm -f "$OPENCODE_AGENT_DIR/$f"
done

Choose a reason for hiding this comment

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

medium

This loop cleans up incorrectly created agent files from the root of $OPENCODE_AGENT_DIR. However, the sub-agent generation logic would have also created files inside a loop-state subdirectory within $OPENCODE_AGENT_DIR. To ensure a complete cleanup, you should also remove this directory. The hardcoded list of files is also a bit brittle.

Suggested change
# Remove loop-state files that were incorrectly created as agents
# These are runtime state files, not agents
for f in ralph-loop.local.md quality-loop.local.md full-loop.local.md loop-state.md re-anchor.md postflight-loop.md; do
rm -f "$OPENCODE_AGENT_DIR/$f"
done
# Remove loop-state files and directory that were incorrectly created as agents
# These are runtime state files, not agents
rm -rf "$OPENCODE_AGENT_DIR/loop-state"
for f in ralph-loop.local.md quality-loop.local.md full-loop.local.md loop-state.md re-anchor.md postflight-loop.md; do
rm -f "$OPENCODE_AGENT_DIR/$f"
done

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.

1 participant