Skip to content

feat: add memory and self-assessment integration to supervisor (t128.6)#380

Merged
marcusquinn merged 2 commits intomainfrom
feature/t128-6-memory-self-assessment
Feb 6, 2026
Merged

feat: add memory and self-assessment integration to supervisor (t128.6)#380
marcusquinn merged 2 commits intomainfrom
feature/t128-6-memory-self-assessment

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 6, 2026

Summary

  • Adds memory integration to the supervisor loop so workers benefit from prior learnings
  • Stores failure/success patterns automatically after task evaluation
  • Runs batch retrospective on completion to capture insights and recurring errors

Changes

Memory Recall Before Dispatch

  • recall_task_memories() queries memory-helper.sh for relevant memories before dispatching a worker
  • Searches both by task description (general relevance) and by task ID (prior failure patterns)
  • Memory context is injected into the worker's prompt via build_dispatch_cmd()

Failure/Success Pattern Storage

  • store_failure_pattern() stores blocked/failed outcomes via memory-helper.sh --auto
  • store_success_pattern() records completions (including retry count) for future reference
  • Transient retries (rate_limited, timeout, interrupted) are skipped to avoid noise
  • All patterns tagged with supervisor,<task_id>,<outcome_type> for targeted recall

Batch Retrospective

  • run_batch_retrospective() runs automatically when a batch completes
  • Calculates success rate, retry totals, and identifies recurring error patterns
  • Stores summary and recurring errors as separate memories
  • Available manually via supervisor-helper.sh retrospective [batch_id]

New Commands

  • recall <task_id> - Preview memories that would be injected for a task
  • retrospective [batch_id] - Run batch retrospective (defaults to most recent completed batch)

Quality

  • Zero ShellCheck violations
  • All new functions follow local var="$1" pattern with explicit returns
  • Graceful degradation when memory-helper.sh is unavailable

Task

Closes t128.6 (Memory and self-assessment integration)

Summary by CodeRabbit

Release Notes

  • New Features
    • Added memory recall to retrieve and apply historical task patterns for improved execution
    • Introduced batch retrospective analysis to review outcomes and generate actionable insights
    • Enhanced task dispatch with integrated memory context for more informed execution
    • Improved logging transparency for memory-informed operations

- Recall relevant memories before dispatch and inject into worker prompt
- Store failure patterns (blocked/failed) via memory-helper.sh --auto
- Store success patterns on task completion for future reference
- Run batch retrospective on completion (stats, recurring errors, insights)
- Add 'recall' command to preview memories for a task
- Add 'retrospective' command for manual batch analysis
- Wire memory storage into all pulse evaluation outcomes
- Zero ShellCheck violations
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 6, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 35 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.

Walkthrough

Added memory recall and storage capabilities to the supervisor script, including functions to fetch prior task memories, persist failure and success patterns, and run batch retrospectives. Integrated memory context into the dispatch flow and batch completion lifecycle.

Changes

Cohort / File(s) Summary
Memory Functions
.agent/scripts/supervisor-helper.sh
Added recall_task_memories() to fetch prior task memories and failure patterns from MEMORY_HELPER; added store_failure_pattern() and store_success_pattern() to persist outcomes with tagging; added run_batch_retrospective() to analyze and surface batch completion insights. Includes guardrails to gracefully skip operations if MEMORY_HELPER is unavailable.
Dispatch Enhancement
.agent/scripts/supervisor-helper.sh
Updated build_dispatch_cmd() signature to accept optional memory_context parameter and integrate it into prompt construction. Updated cmd_dispatch() to recall memories before dispatch and pass context to build_dispatch_cmd.
Command Handlers & Integration
.agent/scripts/supervisor-helper.sh
Added public commands cmd_recall() and cmd_retrospective() with help text. Integrated memory pattern storage into pulse dispatch loop (success, retry, blocked, failed outcomes). Triggered batch retrospective in check_batch_completion() upon batch completion. Updated main command dispatch and help text to expose new commands.

Sequence Diagram

sequenceDiagram
    participant Supervisor as Supervisor Script
    participant Memory as Memory Helper
    participant Dispatch as Dispatch Engine
    
    Supervisor->>Memory: recall_task_memories(task_id)
    Memory-->>Supervisor: task memories & patterns
    Supervisor->>Dispatch: build_dispatch_cmd(..., memory_context)
    Dispatch->>Dispatch: inject memory into prompt
    Dispatch-->>Supervisor: enhanced dispatch command
    Supervisor->>Dispatch: execute dispatch
    Dispatch-->>Supervisor: outcome
    Supervisor->>Memory: store_failure_pattern() or store_success_pattern()
    Memory-->>Supervisor: pattern stored
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • #351: Memory-helper interface changes (namespace flag and invocation semantics) directly affect the new recall_task_memories and pattern storage calls introduced here.

Poem

🧠 Memory awakens in the pulse,
Each pattern, each outcome stored with care,
Dispatch now recalls, learns, and trusts
Batch retrospectives paint insights in the air,
DevOps with the wisdom of the past.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding memory and self-assessment integration to the supervisor script, which aligns directly with the changeset's core functionality.
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 unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t128-6-memory-self-assessment

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.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Fri Feb 6 05:18:57 UTC 2026: Code review monitoring started
Fri Feb 6 05:18:57 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 20
Fri Feb 6 05:18:57 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Fri Feb 6 05:18:59 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 20
  • VULNERABILITIES: 0

Generated on: Fri Feb 6 05:19:02 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.agent/scripts/supervisor-helper.sh (1)

1107-1141: ⚠️ Potential issue | 🔴 Critical

Multi-line prompt gets fragmented into separate CLI arguments.

build_dispatch_cmd outputs one array element per line. Before this PR the prompt was a single line (/full-loop $task_id), so echo "$prompt" produced one line → one array element. Now, when memory_context is non-empty, the prompt contains embedded newlines. Each line of the prompt becomes a separate element in cmd_parts (via the read -r loop at Lines 1336-1338), so the CLI receives the prompt as multiple positional arguments instead of one.

For example, opencode run --format json --title t001 "/full-loop t001" "" "## Relevant Memories" "line2" ... — the memory context is not treated as part of the prompt argument.

The safest fix is to use a NUL-delimited protocol between build_dispatch_cmd and its consumer so newlines inside a single argument are preserved.

🐛 Proposed fix: NUL-delimited output + `read -d ''` consumer

In build_dispatch_cmd, replace echo with printf '%s\0':

     if [[ "$ai_cli" == "opencode" ]]; then
-        echo "opencode"
-        echo "run"
-        echo "--format"
-        echo "json"
-        echo "--title"
-        echo "$task_id"
-        echo "$prompt"
+        printf '%s\0' "opencode" "run" "--format" "json" "--title" "$task_id" "$prompt"
     else
         # claude CLI
-        echo "claude"
-        echo "-p"
-        echo "$prompt"
-        echo "--output-format"
-        echo "json"
+        printf '%s\0' "claude" "-p" "$prompt" "--output-format" "json"
     fi

And update the consumer at Lines 1336-1338:

     local -a cmd_parts=()
-    while IFS= read -r part; do
+    while IFS= read -r -d '' part; do
         cmd_parts+=("$part")
     done < <(build_dispatch_cmd "$task_id" "$worktree_path" "$log_file" "$ai_cli" "$memory_context")
🧹 Nitpick comments (1)
.agent/scripts/supervisor-helper.sh (1)

2590-2706: Solid retrospective implementation; minor tr usage nit.

Line 2663: tr '\n' '; 'tr maps individual characters, so this maps newline→semicolon and the space in set2 is effectively ignored. The output will lack the intended space separator between error entries.

🔧 Use `sed` or `paste` for the intended "; " delimiter
-        retro_content+=" | Common errors: $(echo "$error_patterns" | tr '\n' '; ' | head -c 200)"
+        retro_content+=" | Common errors: $(echo "$error_patterns" | sed ':a;N;$!ba;s/\n/; /g' | head -c 200)"

Or alternatively with paste:

-        retro_content+=" | Common errors: $(echo "$error_patterns" | tr '\n' '; ' | head -c 200)"
+        retro_content+=" | Common errors: $(echo "$error_patterns" | paste -sd ';' - | sed 's/;/; /g' | head -c 200)"

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Fri Feb 6 05:24:21 UTC 2026: Code review monitoring started
Fri Feb 6 05:24:21 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 21
Fri Feb 6 05:24:22 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Fri Feb 6 05:24:24 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 21
  • VULNERABILITIES: 0

Generated on: Fri Feb 6 05:24:26 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 6, 2026

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