Skip to content

t1085.2: AI Supervisor reasoning engine#1609

Merged
marcusquinn merged 1 commit intomainfrom
feature/t1085.2
Feb 18, 2026
Merged

t1085.2: AI Supervisor reasoning engine#1609
marcusquinn merged 1 commit intomainfrom
feature/t1085.2

Conversation

@marcusquinn
Copy link
Owner

Summary

  • Create supervisor/ai-reason.sh — opus-tier AI reasoning engine for the supervisor
  • Spawns AI session with full project context (from t1085.1's build_ai_context)
  • AI reasons about 5 key areas: solvability, verification, linkage, communication, priority
  • Outputs structured JSON action plan with 7 action types
  • Supports dry-run mode for testing without AI API calls
  • Interval-based scheduling with configurable cooldown (default: 30min)
  • Full audit trail in ~/.aidevops/logs/ai-supervisor/
  • Adds ai-reason, ai-status CLI commands

Action Types

The AI can propose:

  1. comment_on_issue — Post comments on GitHub issues
  2. create_task — Add tasks to TODO.md
  3. create_subtasks — Break down existing tasks
  4. flag_for_review — Flag issues for human review
  5. adjust_priority — Suggest task reordering
  6. close_verified — Close verified issues (with evidence check)
  7. request_info — Ask for clarification on issues

Testing

# Dry-run (no AI calls, generates context + prompt log)
supervisor-helper.sh ai-reason dry-run

# Check status
supervisor-helper.sh ai-status

TODO Reference

Create supervisor/ai-reason.sh that spawns an opus-tier AI session with
project context and has it reason about:

- Issue solvability (can open issues be broken into tasks?)
- Verification (have closed issues been properly verified?)
- Linkage (do closed issues have linked PRs?)
- Communication (should any issues get a comment?)
- Priority (what should be worked on next?)

Features:
- Structured JSON action plan output (7 action types)
- Dry-run mode for testing without AI calls
- Interval-based scheduling (default: every 30min)
- Full audit trail in dedicated log directory
- Robust JSON extraction from AI responses (4 parsing strategies)
- Adds ai-reason, ai-status CLI commands to supervisor
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 10 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t1085.2

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 significantly enhances the supervisor's intelligence by integrating an autonomous AI reasoning engine. This engine will proactively analyze the project's current state, identify areas needing attention, and propose actionable steps in a structured format. This advancement aims to streamline project management, automate routine decision-making, and improve overall project flow by leveraging AI to maintain oversight and suggest interventions.

Highlights

  • New AI Reasoning Engine: Introduced supervisor/ai-reason.sh, an opus-tier AI reasoning engine for the supervisor, designed to analyze project state and propose structured action plans.
  • Comprehensive AI Analysis: The AI reasons about five key areas: solvability, verification, linkage, communication, and priority, utilizing full project context built from ai-context.sh.
  • Structured Action Plans: The engine outputs structured JSON action plans supporting seven distinct action types, including commenting on issues, creating tasks, flagging for review, adjusting priority, closing verified issues, and requesting information.
  • New CLI Commands: Added ai-reason to trigger the AI reasoning process and ai-status to check the AI supervisor's last run, total runs, and configuration.
  • Operational Features: Includes a dry-run mode for testing without AI API calls, interval-based scheduling with a configurable cooldown, and a full audit trail logged in ~/.aidevops/logs/ai-supervisor/.
Changelog
  • .agents/scripts/supervisor-helper.sh
    • Sourced the new ai-reason.sh module to integrate the AI reasoning capabilities.
    • Added ai-reason command to the main function to execute the AI reasoning cycle.
    • Implemented ai-status command to display the current status and configuration of the AI supervisor.
  • .agents/scripts/supervisor/ai-reason.sh
    • Created a new shell script to house the core AI reasoning logic.
    • Implemented run_ai_reasoning function to orchestrate context building, prompt generation, AI interaction, and action plan parsing.
    • Defined build_reasoning_prompt to construct the system prompt, outlining the AI's role, capabilities, analysis framework, and output format.
    • Developed extract_action_plan to robustly parse JSON action plans from various AI response formats, including markdown code blocks.
    • Added should_run_ai_reasoning function to manage the execution frequency based on configured intervals and last run timestamps.
    • Included a CLI entry point for standalone testing and debugging of the AI reasoning engine.
Activity
  • No human activity (comments, reviews) has occurred 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

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Wed Feb 18 01:16:08 UTC 2026: Code review monitoring started
Wed Feb 18 01:16:08 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 18

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 18
  • VULNERABILITIES: 0

Generated on: Wed Feb 18 01:16:10 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@marcusquinn marcusquinn merged commit 50ce23c into main Feb 18, 2026
10 of 11 checks passed
marcusquinn added a commit that referenced this pull request Feb 18, 2026
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 a significant new feature: an AI reasoning engine for the supervisor. The new script ai-reason.sh is well-structured and the integration into supervisor-helper.sh is clean. My review focuses on improving the robustness of the new code. I've suggested changes to make an arithmetic calculation safer, to improve the error handling of the JSON parsing logic by using exit codes, and to fix a bug in the argument parsing for the standalone script mode. These improvements will make the new functionality more reliable and easier to maintain.

Comment on lines +700 to +702
echo " Enabled: ${SUPERVISOR_AI_ENABLED:-true}"
echo " Interval: ${SUPERVISOR_AI_INTERVAL:-15} pulses (~$((${SUPERVISOR_AI_INTERVAL:-15} * 2))min)"
echo " Log dir: ${AI_REASON_LOG_DIR:-$HOME/.aidevops/logs/ai-supervisor}"

Choose a reason for hiding this comment

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

medium

The arithmetic expression ((${SUPERVISOR_AI_INTERVAL:-15} * 2)) on line 701 is not safe under set -e. If SUPERVISOR_AI_INTERVAL is set to a non-numeric value, this command will fail and cause the script to exit. According to the repository style guide (line 13), arithmetic that might fail should be guarded.

To make this more robust, pre-calculate the value with a fallback.

Suggested change
echo " Enabled: ${SUPERVISOR_AI_ENABLED:-true}"
echo " Interval: ${SUPERVISOR_AI_INTERVAL:-15} pulses (~$((${SUPERVISOR_AI_INTERVAL:-15} * 2))min)"
echo " Log dir: ${AI_REASON_LOG_DIR:-$HOME/.aidevops/logs/ai-supervisor}"
echo " Enabled: ${SUPERVISOR_AI_ENABLED:-true}"
local interval_minutes
interval_minutes=$(( ${SUPERVISOR_AI_INTERVAL:-15} * 2 )) 2>/dev/null || interval_minutes="?"
echo " Interval: ${SUPERVISOR_AI_INTERVAL:-15} pulses (~${interval_minutes}min)"
echo " Log dir: ${AI_REASON_LOG_DIR:-$HOME/.aidevops/logs/ai-supervisor}"
References
  1. The style guide requires that arithmetic operations that might fail (e.g., with non-numeric input) must be guarded to prevent script termination under set -e. (link)

Comment on lines +152 to +164
local action_plan
action_plan=$(extract_action_plan "$ai_result")

if [[ -z "$action_plan" || "$action_plan" == "null" ]]; then
log_warn "AI Reasoning: no parseable action plan in response"
{
echo "## Parsing Result"
echo ""
echo "Status: FAILED - no parseable JSON action plan"
} >>"$reason_log"
echo '{"error":"no_action_plan","actions":[]}'
return 1
fi

Choose a reason for hiding this comment

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

medium

To properly handle the error-signaling exit code from extract_action_plan (as suggested in other comments), the call site should be updated to check the exit code directly. This is a more robust way to handle errors in shell scripts, especially with set -e enabled.

Suggested change
local action_plan
action_plan=$(extract_action_plan "$ai_result")
if [[ -z "$action_plan" || "$action_plan" == "null" ]]; then
log_warn "AI Reasoning: no parseable action plan in response"
{
echo "## Parsing Result"
echo ""
echo "Status: FAILED - no parseable JSON action plan"
} >>"$reason_log"
echo '{"error":"no_action_plan","actions":[]}'
return 1
fi
local action_plan
if ! action_plan=$(extract_action_plan "$ai_result"); then
log_warn "AI Reasoning: no parseable action plan in response"
{
echo "## Parsing Result"
echo ""
echo "Status: FAILED - no parseable JSON action plan"
} >>"$reason_log"
echo '{"error":"no_action_plan","actions":[]}'
return 1
fi
References
  1. Functions that wrap a command should propagate its exit code to the caller. Callers should check the exit code to handle errors robustly, aligning with the principle of not masking errors with return 0.

Comment on lines +291 to +294
if [[ -z "$response" ]]; then
echo ""
return 0
fi

Choose a reason for hiding this comment

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

medium

This function should signal a failure to parse using a non-zero exit code instead of returning an empty string with a success code. This makes error handling at the call site more robust and idiomatic for shell scripts. This change aligns with the general rule of not masking errors with return 0.

This change should be paired with another change at the end of the function and at the call site in run_ai_reasoning.

Suggested change
if [[ -z "$response" ]]; then
echo ""
return 0
fi
if [[ -z "$response" ]]; then
return 1
fi
References
  1. Functions should not mask potential errors with a hardcoded return 0. Instead, they should propagate failure by returning a non-zero exit code, allowing callers to handle errors robustly.

Comment on lines +341 to +344
# Failed to parse
echo ""
return 0
}

Choose a reason for hiding this comment

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

medium

On failure to parse, the function should return a non-zero exit code to signal an error, rather than returning an empty string with exit code 0. This aligns with the general rule of not masking errors and allows the caller to reliably detect and handle parsing failures.

Suggested change
# Failed to parse
echo ""
return 0
}
# Failed to parse
return 1
}
References
  1. Functions should not mask potential errors with a hardcoded return 0. Instead, they should propagate failure by returning a non-zero exit code, allowing callers to handle errors robustly.

Comment on lines +455 to +481
while [[ $# -gt 0 ]]; do
case "$1" in
--mode)
mode="$2"
shift 2
;;
--repo)
repo_path="$2"
shift 2
;;
--help | -h)
echo "Usage: ai-reason.sh [--mode full|dry-run|read-only] [--repo /path]"
echo ""
echo "Run AI supervisor reasoning cycle."
echo ""
echo "Options:"
echo " --mode full|dry-run Reasoning mode (default: full)"
echo " --repo /path Repository path (default: git root)"
echo " --help Show this help"
exit 0
;;
*)
echo "Unknown option: $1" >&2
exit 1
;;
esac
done

Choose a reason for hiding this comment

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

medium

The argument parsing logic is not robust. If --mode or --repo is the last argument on the command line, $2 will be empty and shift 2 will cause the script to exit with an error because of set -e. You should validate that an argument is provided for these options.

 while [[ $# -gt 0 ]]; do
  case "$1" in
  --mode)
   if [[ -z "$2" ]]; then
    echo "Error: --mode requires an argument." >&2
    exit 1
   fi
   mode="$2"
   shift 2
   ;;
  --repo)
   if [[ -z "$2" ]]; then
    echo "Error: --repo requires an argument." >&2
    exit 1
   fi
   repo_path="$2"
   shift 2
   ;;
  --help | -h)
   echo "Usage: ai-reason.sh [--mode full|dry-run|read-only] [--repo /path]"
   echo ""
   echo "Run AI supervisor reasoning cycle."
   echo ""
   echo "Options:"
   echo "  --mode full|dry-run   Reasoning mode (default: full)"
   echo "  --repo /path          Repository path (default: git root)"
   echo "  --help                Show this help"
   exit 0
   ;;
  *)
   echo "Unknown option: $1" >&2
   exit 1
   ;;
  esac
 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