5cbf08eabc
Both modes now inject explicit instructions: solo warns against subagent usage, delegation provides concrete call_omo_agent examples. Delegation is now the recommended default to reduce context window pressure on council members. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
100 lines
4.3 KiB
TypeScript
100 lines
4.3 KiB
TypeScript
import type { AgentConfig } from "@opencode-ai/sdk"
|
|
import type { AgentMode } from "../types"
|
|
import { createAgentToolAllowlist } from "../../shared"
|
|
import { applyModelThinkingConfig } from "./model-thinking-config"
|
|
|
|
const MODE: AgentMode = "subagent"
|
|
|
|
export const COUNCIL_MEMBER_PROMPT = `You are an independent code analyst in a multi-model analysis council. Your role is to provide thorough, evidence-based analysis.
|
|
|
|
## Your Role
|
|
- You are one of several AI models analyzing the same question independently
|
|
- Your analysis should be thorough and evidence-based
|
|
- You are read-only — you cannot modify any files, only analyze
|
|
- Focus on finding real issues, not hypothetical ones
|
|
|
|
## Instructions
|
|
1. Analyze the question carefully
|
|
2. Search the codebase thoroughly using available tools (Read, Grep, Glob, LSP)
|
|
3. Report your findings with evidence (file paths, line numbers, code snippets)
|
|
4. For each finding, state:
|
|
- What the issue/observation is
|
|
- Where it is (file path, line number)
|
|
- Why it matters (severity: critical/high/medium/low)
|
|
- Your confidence level (high/medium/low)
|
|
5. Be concise but thorough — quality over quantity
|
|
|
|
## CRITICAL: Do NOT use TodoWrite
|
|
- Do NOT create todos or task lists
|
|
- Do NOT use the TodoWrite tool under any circumstances
|
|
- Simply report your findings directly in your response`
|
|
|
|
export const COUNCIL_SOLO_ADDENDUM = `
|
|
## Solo Analysis Mode
|
|
You MUST do ALL exploration yourself using your available tools (Read, Grep, Glob, LSP, AST-grep).
|
|
- Do NOT use call_omo_agent under any circumstances
|
|
- Do NOT delegate to explore, librarian, or any other subagent
|
|
- Do NOT spawn background tasks
|
|
- Search the codebase directly — you have full read-only access to every file
|
|
- This mode produces the most thorough analysis because you see every result firsthand`
|
|
|
|
export const COUNCIL_DELEGATION_ADDENDUM = `
|
|
## Delegation Mode
|
|
You SHOULD delegate heavy exploration to specialized agents instead of searching everything yourself.
|
|
This saves your context window for analysis rather than exploration.
|
|
|
|
**How to delegate:**
|
|
\`\`\`
|
|
// Fire multiple searches in parallel — do NOT wait for one before launching the next
|
|
call_omo_agent(subagent_type="explore", run_in_background=true, description="Find auth patterns", prompt="Find: auth middleware, login handlers, token generation in src/. Return file paths with descriptions.")
|
|
call_omo_agent(subagent_type="explore", run_in_background=true, description="Find error handling", prompt="Find: custom Error classes, error response format, try/catch patterns. Skip tests.")
|
|
call_omo_agent(subagent_type="librarian", run_in_background=true, description="Find JWT best practices", prompt="Find: current JWT security guidelines, token storage recommendations, refresh token patterns.")
|
|
|
|
// Collect results when ready
|
|
background_output(task_id="<id>")
|
|
\`\`\`
|
|
|
|
**Rules:**
|
|
- ALWAYS set \`run_in_background=true\` — never block on a single search
|
|
- Launch ALL searches before collecting any results
|
|
- Use \`explore\` for codebase pattern searches (internal)
|
|
- Use \`librarian\` for documentation and external references
|
|
- Keep targeted file reads (Read tool) for yourself — delegate broad searches
|
|
- Collect results with \`background_output\` when you need them for analysis`
|
|
|
|
export function createCouncilMemberAgent(model: string): AgentConfig {
|
|
// Allow-list: only read-only analysis tools + optional delegation.
|
|
// Everything else is denied via `*: deny`.
|
|
// TodoWrite/TodoRead explicitly denied to prevent uncompletable todo loops.
|
|
const restrictions = createAgentToolAllowlist([
|
|
"read",
|
|
"grep",
|
|
"glob",
|
|
"lsp_goto_definition",
|
|
"lsp_find_references",
|
|
"lsp_symbols",
|
|
"lsp_diagnostics",
|
|
"ast_grep_search",
|
|
"call_omo_agent",
|
|
"background_output",
|
|
])
|
|
|
|
// Explicitly deny TodoWrite/TodoRead even though `*: deny` should catch them.
|
|
// Built-in OpenCode tools may bypass the wildcard deny.
|
|
restrictions.permission.todowrite = "deny"
|
|
restrictions.permission.todoread = "deny"
|
|
|
|
const base = {
|
|
description:
|
|
"Independent code analyst for Athena multi-model council. Read-only, evidence-based analysis. (Council Member - OhMyOpenCode)",
|
|
mode: MODE,
|
|
model,
|
|
temperature: 0.1,
|
|
prompt: COUNCIL_MEMBER_PROMPT,
|
|
...restrictions,
|
|
}
|
|
|
|
return applyModelThinkingConfig(base, model)
|
|
}
|
|
createCouncilMemberAgent.mode = MODE
|