Skip to content

Conversation

@synergy0422
Copy link

@synergy0422 synergy0422 commented Jan 12, 2026

Summary

This PR introduces a runtime agent output validation mechanism to enforce clear responsibility boundaries between agents (e.g. Commander vs Oracle) and make violations detectable, testable, and auditable.

Key goals:

  • Prevent role overreach (e.g. planning agents outputting implementation code)
  • Replace prompt-only constraints with engine-level validation
  • Provide log-based evidence (PASS / FAIL) instead of model self-assertion

Changes

Core

  • Added agent-output-validator hook to the runtime execution chain
  • Validator is executed after agent output is produced and before final delivery

Agent Responsibilities

  • Commander
    • Planning / architecture / specification only
    • Strict output format validation
    • Implementation code → FAIL
  • Oracle
    • Deep analysis allowed
    • Implementation code in restricted contexts → FAIL

Validation & Logging

  • Separate validators for Commander and Reviewer
  • Deterministic PASS / FAIL results appended to output
  • Runtime logs provide grep-able evidence:
    • Validating Commander output: PASS/FAIL
    • Validating Oracle output: PASS/FAIL

Slash Command

  • Added /commander builtin command template
  • Ensures a deterministic, non–prompt-based entry point for Commander usage

Schema & Wiring

  • Updated schema and hook registration
  • All changes are wired through existing extension points (no large refactor)

Testing

Manual verification performed:

  • bun run build passes (571 modules, 0 errors)
  • Runtime logs confirm:
    • Hook execution
    • Correct agent type detection
    • PASS / FAIL behavior for both Commander and Oracle

Example log evidence:


Summary by cubic

Adds a runtime agent-output-validator hook that enforces role boundaries for Commander and Oracle by validating output format and detecting implementation code. Violations are surfaced with deterministic PASS/FAIL logs and an appended error message, preventing bad outputs from reaching users.

  • New Features

    • Added agent-output-validator hook (runs on task/call_omo_agent/background_task) to check Oracle and Commander outputs and append errors on failure.
    • Enforced Oracle review format (VERDICT + CRITERIA CHECK) and Commander spec sections; detects edit/write/bash usage and substantial code blocks.
    • Introduced Commander subagent and a /commander builtin command template for architecture/planning.
    • Exported commander/reviewer validators; registered the hook; updated schema to include "agent-output-validator".
    • Tightened Oracle prompt and denied write, edit, task, and background_task tools.
  • Migration

    • Enable the "agent-output-validator" hook in config.
    • Run build; the hook integrates into tool.execute.after with no breaking changes.
    • Use /commander for deterministic Commander requests.

Written for commit 5a80b7c. Summary will update on new commits.

@github-actions
Copy link
Contributor

Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement (CLA).

To sign the CLA, please comment on this PR with:

I have read the CLA Document and I hereby sign the CLA

This is a one-time requirement. Once signed, all your future contributions will be automatically accepted.


I have read the CLA Document and I hereby sign the CLA


opencode seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@synergy0422
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

9 issues found across 27 files

Confidence score: 2/5

  • src/shared/commander-validator.ts currently enforces section names/format that diverge from the Commander template, so every valid Commander response will still be rejected by the validator.
  • src/features/builtin-commands/commands.ts and templates/commander.md hard-code an unsupported subagent_type="commander", meaning the command invocation will always fail at runtime because only "explore" or "librarian" are accepted.
  • src/shared/reviewer-validator.ts computes hasTable but never checks it, allowing malformed CRITERIA CHECK tables to slip through and undermining the reviewer contract.
  • Pay close attention to src/shared/commander-validator.ts, src/features/builtin-commands/commands.ts, and src/features/builtin-commands/templates/commander.md - they need to align with the actual Commander contract and allowed subagent types.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="patches/IMPLEMENTATION_SUMMARY.md">

<violation number="1" location="patches/IMPLEMENTATION_SUMMARY.md:82">
P2: Implementation summary is outdated/inaccurate: claims validators are not integrated, but the agent-output-validator hook is wired into runtime execution.</violation>
</file>

<file name="patches/AGENT_RESPONSIBILITY_VERIFICATION.md">

<violation number="1" location="patches/AGENT_RESPONSIBILITY_VERIFICATION.md:193">
P2: Documentation incorrectly claims Commander agent file does not exist even though `src/agents/commander.ts` is present</violation>
</file>

<file name="src/features/builtin-commands/templates/commander.md">

<violation number="1" location="src/features/builtin-commands/templates/commander.md:7">
P2: Template instructs calling task tool with unsupported subagent_type "commander"; runtime only allows "explore" or "librarian", so this command will always be rejected.</violation>
</file>

<file name="src/agents/oracle.ts">

<violation number="1" location="src/agents/oracle.ts:98">
P2: System prompt falsely claims no intermediate processing even though the agent-output-validator hook appends content to outputs on validation failure, causing misaligned instructions.</violation>

<violation number="2" location="src/agents/oracle.ts:119">
P2: Oracle prompt contains contradictory directives (advisor with action plan vs reviewer forbidden to give solutions/forced PASS/FAIL format), making the role unclear and outputs likely non-compliant.</violation>
</file>

<file name="src/features/builtin-commands/commands.ts">

<violation number="1" location="src/features/builtin-commands/commands.ts:52">
P1: Commander command hard-codes subagent_type="commander" but the task tool only allows "explore" or "librarian", so the command will fail at runtime.</violation>
</file>

<file name="src/shared/reviewer-validator.ts">

<violation number="1" location="src/shared/reviewer-validator.ts:45">
P2: CRITERIA CHECK table format is not enforced: `hasTable` is computed but never validated, so malformed tables still pass</violation>

<violation number="2" location="src/shared/reviewer-validator.ts:48">
P2: Criteria row detection is not scoped to the CRITERIA CHECK section, allowing unrelated table rows elsewhere to satisfy the required entry check.</violation>
</file>

<file name="src/shared/commander-validator.ts">

<violation number="1" location="src/shared/commander-validator.ts:34">
P1: Commander validator hardcodes section names/format that contradict the actual Commander template, causing guaranteed false failures</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

commander: {
description: "(builtin) Call Commander agent for architecture and planning tasks",
template: `<command-instruction>
Use task tool with subagent_type="commander" to invoke Commander agent.
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

Choose a reason for hiding this comment

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

P1: Commander command hard-codes subagent_type="commander" but the task tool only allows "explore" or "librarian", so the command will fail at runtime.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/features/builtin-commands/commands.ts, line 52:

<comment>Commander command hard-codes subagent_type="commander" but the task tool only allows "explore" or "librarian", so the command will fail at runtime.</comment>

<file context>
@@ -38,9 +39,29 @@ ${CANCEL_RALPH_TEMPLATE}
+  commander: {
+    description: "(builtin) Call Commander agent for architecture and planning tasks",
+    template: `<command-instruction>
+Use task tool with subagent_type="commander" to invoke Commander agent.
+
+Task will call Commander with the following system prompt:
</file context>
Fix with Cubic

const duplicates: string[] = [];

// Define required section markers
const requiredSections = [
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

Choose a reason for hiding this comment

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

P1: Commander validator hardcodes section names/format that contradict the actual Commander template, causing guaranteed false failures

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/shared/commander-validator.ts, line 34:

<comment>Commander validator hardcodes section names/format that contradict the actual Commander template, causing guaranteed false failures</comment>

<file context>
@@ -0,0 +1,91 @@
+  const duplicates: string[] = [];
+
+  // Define required section markers
+  const requiredSections = [
+    "SPEC",
+    "ACCEPTANCE CRITERIA",
</file context>
Fix with Cubic


1. **Automatic routing** based on complexity - GLM-4.7 will handle everything by default
2. **Escalation logic** - No automatic escalation to Commander/Codex
3. **Prompt-level validation** - Validators exist but are not integrated
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

Choose a reason for hiding this comment

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

P2: Implementation summary is outdated/inaccurate: claims validators are not integrated, but the agent-output-validator hook is wired into runtime execution.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At patches/IMPLEMENTATION_SUMMARY.md, line 82:

<comment>Implementation summary is outdated/inaccurate: claims validators are not integrated, but the agent-output-validator hook is wired into runtime execution.</comment>

<file context>
@@ -0,0 +1,181 @@
+
+1. **Automatic routing** based on complexity - GLM-4.7 will handle everything by default
+2. **Escalation logic** - No automatic escalation to Commander/Codex
+3. **Prompt-level validation** - Validators exist but are not integrated
+4. **Structured decision packets** - Not implemented due to encoding issues
+
</file context>
Suggested change
3. **Prompt-level validation** - Validators exist but are not integrated
3. **Prompt-level validation** - Runtime agent-output-validator hook is integrated (Oracle/Commander output validation active)
Fix with Cubic


### Commander Agent Status

**Status**: ⚠️ Commander agent file does not exist in codebase
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

Choose a reason for hiding this comment

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

P2: Documentation incorrectly claims Commander agent file does not exist even though src/agents/commander.ts is present

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At patches/AGENT_RESPONSIBILITY_VERIFICATION.md, line 193:

<comment>Documentation incorrectly claims Commander agent file does not exist even though `src/agents/commander.ts` is present</comment>

<file context>
@@ -0,0 +1,528 @@
+
+### Commander Agent Status
+
+**Status**: ⚠️ Commander agent file does not exist in codebase
+
+**But**: Commander is configured in `oh-my-opencode.json` and may be invoked via `/commander` slash command
</file context>
Suggested change
**Status**: ⚠️ Commander agent file does not exist in codebase
**Status**: Commander agent implemented (`src/agents/commander.ts`)
Fix with Cubic


# /commander

Use task tool with subagent_type="commander" to invoke Commander agent.
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

Choose a reason for hiding this comment

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

P2: Template instructs calling task tool with unsupported subagent_type "commander"; runtime only allows "explore" or "librarian", so this command will always be rejected.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/features/builtin-commands/templates/commander.md, line 7:

<comment>Template instructs calling task tool with unsupported subagent_type "commander"; runtime only allows "explore" or "librarian", so this command will always be rejected.</comment>

<file context>
@@ -0,0 +1,33 @@
+
+# /commander
+
+Use task tool with subagent_type="commander" to invoke Commander agent.
+
+Task will call Commander with the following system prompt:
</file context>
Fix with Cubic

## Critical Note
Your response goes directly to the user with no intermediate processing. Make your final message self-contained: a clear recommendation they can act on immediately, covering both what to do and why.`
Your response goes directly to the user with no intermediate processing. Make your final message self-contained: a clear recommendation they can act on immediately, covering both what to do and why.
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

Choose a reason for hiding this comment

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

P2: System prompt falsely claims no intermediate processing even though the agent-output-validator hook appends content to outputs on validation failure, causing misaligned instructions.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agents/oracle.ts, line 98:

<comment>System prompt falsely claims no intermediate processing even though the agent-output-validator hook appends content to outputs on validation failure, causing misaligned instructions.</comment>

<file context>
@@ -83,19 +83,62 @@ Organize your final answer in three tiers:
 ## Critical Note
 
-Your response goes directly to the user with no intermediate processing. Make your final message self-contained: a clear recommendation they can act on immediately, covering both what to do and why.`
+Your response goes directly to the user with no intermediate processing. Make your final message self-contained: a clear recommendation they can act on immediately, covering both what to do and why.
+
+---
</file context>
Suggested change
Your response goes directly to the user with no intermediate processing. Make your final message self-contained: a clear recommendation they can act on immediately, covering both what to do and why.
Your response is validated before delivery; ensure it meets the required format, or validation errors may be appended. Make your final message self-contained: a clear recommendation they can act on immediately, covering both what to do and why.
Fix with Cubic

**You MUST**:
1. **Provide structured reviews only**
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

Choose a reason for hiding this comment

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

P2: Oracle prompt contains contradictory directives (advisor with action plan vs reviewer forbidden to give solutions/forced PASS/FAIL format), making the role unclear and outputs likely non-compliant.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agents/oracle.ts, line 119:

<comment>Oracle prompt contains contradictory directives (advisor with action plan vs reviewer forbidden to give solutions/forced PASS/FAIL format), making the role unclear and outputs likely non-compliant.</comment>

<file context>
@@ -83,19 +83,62 @@ Organize your final answer in three tiers:
+
+**You MUST**:
+
+1. **Provide structured reviews only**
+   - Output MUST start with: VERDICT: [PASS|FAIL]
+   - Output MUST include: CRITERIA CHECK table with format:
</file context>
Fix with Cubic

const hasTable = /\|\s*\d+\s*\|\s*(Yes|No)\s*\|/i.test(output);

// 5. Check for at least one criteria row
const criteriaEntries = output.match(/\|\s*\d+\s*\|[^\n]+/gm);
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

Choose a reason for hiding this comment

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

P2: Criteria row detection is not scoped to the CRITERIA CHECK section, allowing unrelated table rows elsewhere to satisfy the required entry check.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/shared/reviewer-validator.ts, line 48:

<comment>Criteria row detection is not scoped to the CRITERIA CHECK section, allowing unrelated table rows elsewhere to satisfy the required entry check.</comment>

<file context>
@@ -0,0 +1,64 @@
+  const hasTable = /\|\s*\d+\s*\|\s*(Yes|No)\s*\|/i.test(output);
+
+  // 5. Check for at least one criteria row
+  const criteriaEntries = output.match(/\|\s*\d+\s*\|[^\n]+/gm);
+  if (!criteriaEntries) {
+    result.errors.push("CRITERIA CHECK table must have at least one entry");
</file context>
Fix with Cubic

}

// 4. Validate CRITERIA CHECK table format
const hasTable = /\|\s*\d+\s*\|\s*(Yes|No)\s*\|/i.test(output);
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

Choose a reason for hiding this comment

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

P2: CRITERIA CHECK table format is not enforced: hasTable is computed but never validated, so malformed tables still pass

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/shared/reviewer-validator.ts, line 45:

<comment>CRITERIA CHECK table format is not enforced: `hasTable` is computed but never validated, so malformed tables still pass</comment>

<file context>
@@ -0,0 +1,64 @@
+  }
+
+  // 4. Validate CRITERIA CHECK table format
+  const hasTable = /\|\s*\d+\s*\|\s*(Yes|No)\s*\|/i.test(output);
+
+  // 5. Check for at least one criteria row
</file context>
Fix with Cubic

@synergy0422
Copy link
Author

recheck

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