Pass available agent metadata to createSisyphusAgent so the delegation table and other dynamic prompt sections are populated instead of being empty. Root cause: buildAgent() only passed `model` to createSisyphusAgent, but not `availableAgents`. This caused the delegation table, tool selection table, and other dynamic sections to be built with empty arrays. Fix: 1. Import all agent metadata exports (*_PROMPT_METADATA) 2. Create agentMetadata map 3. Build non-Sisyphus agents first, collecting AvailableAgent[] 4. Pass availableAgents to createSisyphusAgent 🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
import type { AgentConfig } from "@opencode-ai/sdk"
|
import type { AgentConfig } from "@opencode-ai/sdk"
|
||||||
import type { BuiltinAgentName, AgentOverrideConfig, AgentOverrides, AgentFactory } from "./types"
|
import type { BuiltinAgentName, AgentOverrideConfig, AgentOverrides, AgentFactory, AgentPromptMetadata } from "./types"
|
||||||
import { createSisyphusAgent } from "./sisyphus"
|
import { createSisyphusAgent } from "./sisyphus"
|
||||||
import { createOracleAgent } from "./oracle"
|
import { createOracleAgent, ORACLE_PROMPT_METADATA } from "./oracle"
|
||||||
import { createLibrarianAgent } from "./librarian"
|
import { createLibrarianAgent, LIBRARIAN_PROMPT_METADATA } from "./librarian"
|
||||||
import { createExploreAgent } from "./explore"
|
import { createExploreAgent, EXPLORE_PROMPT_METADATA } from "./explore"
|
||||||
import { createFrontendUiUxEngineerAgent } from "./frontend-ui-ux-engineer"
|
import { createFrontendUiUxEngineerAgent, FRONTEND_PROMPT_METADATA } from "./frontend-ui-ux-engineer"
|
||||||
import { createDocumentWriterAgent } from "./document-writer"
|
import { createDocumentWriterAgent, DOCUMENT_WRITER_PROMPT_METADATA } from "./document-writer"
|
||||||
import { createMultimodalLookerAgent } from "./multimodal-looker"
|
import { createMultimodalLookerAgent, MULTIMODAL_LOOKER_PROMPT_METADATA } from "./multimodal-looker"
|
||||||
|
import type { AvailableAgent } from "./sisyphus-prompt-builder"
|
||||||
import { deepMerge } from "../shared"
|
import { deepMerge } from "../shared"
|
||||||
|
|
||||||
type AgentSource = AgentFactory | AgentConfig
|
type AgentSource = AgentFactory | AgentConfig
|
||||||
@@ -21,6 +22,19 @@ const agentSources: Record<BuiltinAgentName, AgentSource> = {
|
|||||||
"multimodal-looker": createMultimodalLookerAgent,
|
"multimodal-looker": createMultimodalLookerAgent,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Metadata for each agent, used to build Sisyphus's dynamic prompt sections
|
||||||
|
* (Delegation Table, Tool Selection, Key Triggers, etc.)
|
||||||
|
*/
|
||||||
|
const agentMetadata: Partial<Record<BuiltinAgentName, AgentPromptMetadata>> = {
|
||||||
|
oracle: ORACLE_PROMPT_METADATA,
|
||||||
|
librarian: LIBRARIAN_PROMPT_METADATA,
|
||||||
|
explore: EXPLORE_PROMPT_METADATA,
|
||||||
|
"frontend-ui-ux-engineer": FRONTEND_PROMPT_METADATA,
|
||||||
|
"document-writer": DOCUMENT_WRITER_PROMPT_METADATA,
|
||||||
|
"multimodal-looker": MULTIMODAL_LOOKER_PROMPT_METADATA,
|
||||||
|
}
|
||||||
|
|
||||||
function isFactory(source: AgentSource): source is AgentFactory {
|
function isFactory(source: AgentSource): source is AgentFactory {
|
||||||
return typeof source === "function"
|
return typeof source === "function"
|
||||||
}
|
}
|
||||||
@@ -76,20 +90,20 @@ export function createBuiltinAgents(
|
|||||||
systemDefaultModel?: string
|
systemDefaultModel?: string
|
||||||
): Record<string, AgentConfig> {
|
): Record<string, AgentConfig> {
|
||||||
const result: Record<string, AgentConfig> = {}
|
const result: Record<string, AgentConfig> = {}
|
||||||
|
const availableAgents: AvailableAgent[] = []
|
||||||
|
|
||||||
for (const [name, source] of Object.entries(agentSources)) {
|
for (const [name, source] of Object.entries(agentSources)) {
|
||||||
const agentName = name as BuiltinAgentName
|
const agentName = name as BuiltinAgentName
|
||||||
|
|
||||||
if (disabledAgents.includes(agentName)) {
|
if (agentName === "Sisyphus") continue
|
||||||
continue
|
if (disabledAgents.includes(agentName)) continue
|
||||||
}
|
|
||||||
|
|
||||||
const override = agentOverrides[agentName]
|
const override = agentOverrides[agentName]
|
||||||
const model = override?.model ?? (agentName === "Sisyphus" ? systemDefaultModel : undefined)
|
const model = override?.model
|
||||||
|
|
||||||
let config = buildAgent(source, model)
|
let config = buildAgent(source, model)
|
||||||
|
|
||||||
if ((agentName === "Sisyphus" || agentName === "librarian") && directory && config.prompt) {
|
if (agentName === "librarian" && directory && config.prompt) {
|
||||||
const envContext = createEnvContext()
|
const envContext = createEnvContext()
|
||||||
config = { ...config, prompt: config.prompt + envContext }
|
config = { ...config, prompt: config.prompt + envContext }
|
||||||
}
|
}
|
||||||
@@ -99,6 +113,33 @@ export function createBuiltinAgents(
|
|||||||
}
|
}
|
||||||
|
|
||||||
result[name] = config
|
result[name] = config
|
||||||
|
|
||||||
|
const metadata = agentMetadata[agentName]
|
||||||
|
if (metadata) {
|
||||||
|
availableAgents.push({
|
||||||
|
name: agentName,
|
||||||
|
description: config.description ?? "",
|
||||||
|
metadata,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!disabledAgents.includes("Sisyphus")) {
|
||||||
|
const sisyphusOverride = agentOverrides["Sisyphus"]
|
||||||
|
const sisyphusModel = sisyphusOverride?.model ?? systemDefaultModel
|
||||||
|
|
||||||
|
let sisyphusConfig = createSisyphusAgent(sisyphusModel, availableAgents)
|
||||||
|
|
||||||
|
if (directory && sisyphusConfig.prompt) {
|
||||||
|
const envContext = createEnvContext()
|
||||||
|
sisyphusConfig = { ...sisyphusConfig, prompt: sisyphusConfig.prompt + envContext }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sisyphusOverride) {
|
||||||
|
sisyphusConfig = mergeAgentConfig(sisyphusConfig, sisyphusOverride)
|
||||||
|
}
|
||||||
|
|
||||||
|
result["Sisyphus"] = sisyphusConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user