fix(agents): resolve skills after agent overrides
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import type { AgentConfig } from "@opencode-ai/sdk"
|
||||
import type { AgentFactory } from "./types"
|
||||
import type { CategoriesConfig, CategoryConfig, GitMasterConfig } from "../config/schema"
|
||||
import type { BrowserAutomationProvider } from "../config/schema"
|
||||
import type { CategoriesConfig, CategoryConfig } from "../config/schema"
|
||||
import { mergeCategories } from "../shared/merge-categories"
|
||||
import { resolveMultipleSkills } from "../features/opencode-skill-loader/skill-content"
|
||||
|
||||
export type AgentSource = AgentFactory | AgentConfig
|
||||
|
||||
@@ -14,10 +12,7 @@ export function isFactory(source: AgentSource): source is AgentFactory {
|
||||
export function buildAgent(
|
||||
source: AgentSource,
|
||||
model: string,
|
||||
categories?: CategoriesConfig,
|
||||
gitMasterConfig?: GitMasterConfig,
|
||||
browserProvider?: BrowserAutomationProvider,
|
||||
disabledSkills?: Set<string>
|
||||
categories?: CategoriesConfig
|
||||
): AgentConfig {
|
||||
const base = isFactory(source) ? source(model) : { ...source }
|
||||
const categoryConfigs: Record<string, CategoryConfig> = mergeCategories(categories)
|
||||
@@ -38,13 +33,5 @@ export function buildAgent(
|
||||
}
|
||||
}
|
||||
|
||||
if (agentWithCategory.skills?.length) {
|
||||
const { resolved } = resolveMultipleSkills(agentWithCategory.skills, { gitMasterConfig, browserProvider, disabledSkills })
|
||||
if (resolved.size > 0) {
|
||||
const skillContent = Array.from(resolved.values()).join("\n\n")
|
||||
base.prompt = skillContent + (base.prompt ? "\n\n" + base.prompt : "")
|
||||
}
|
||||
}
|
||||
|
||||
return base
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { AgentConfig } from "@opencode-ai/sdk"
|
||||
import type { BrowserAutomationProvider, GitMasterConfig } from "../config/schema"
|
||||
import { resolveMultipleSkills } from "../features/opencode-skill-loader/skill-content"
|
||||
|
||||
type AgentConfigWithSkills = AgentConfig & { skills?: string[] }
|
||||
|
||||
export function resolveAgentSkills(
|
||||
config: AgentConfig,
|
||||
options: {
|
||||
gitMasterConfig?: GitMasterConfig
|
||||
browserProvider?: BrowserAutomationProvider
|
||||
disabledSkills?: Set<string>
|
||||
} = {}
|
||||
): AgentConfig {
|
||||
const { skills, ...configWithoutSkills } = config as AgentConfigWithSkills
|
||||
if (!skills?.length) return configWithoutSkills
|
||||
|
||||
const { resolved } = resolveMultipleSkills(skills, options)
|
||||
if (resolved.size === 0) return configWithoutSkills
|
||||
|
||||
const skillContent = Array.from(resolved.values()).join("\n\n")
|
||||
return {
|
||||
...configWithoutSkills,
|
||||
prompt: skillContent + (configWithoutSkills.prompt ? "\n\n" + configWithoutSkills.prompt : ""),
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import type { BrowserAutomationProvider } from "../../config/schema"
|
||||
import type { AvailableAgent } from "../dynamic-agent-prompt-builder"
|
||||
import { AGENT_MODEL_REQUIREMENTS, isModelAvailable } from "../../shared"
|
||||
import { buildAgent, isFactory } from "../agent-builder"
|
||||
import { resolveAgentSkills } from "../agent-skill-resolution"
|
||||
import { applyOverrides } from "./agent-overrides"
|
||||
import { applyEnvironmentContext } from "./environment-context"
|
||||
import { applyModelResolution, getFirstFallbackModel } from "./model-resolution"
|
||||
@@ -92,7 +93,7 @@ export function collectPendingBuiltinAgents(input: {
|
||||
if (!resolution) continue
|
||||
const { model, variant: resolvedVariant } = resolution
|
||||
|
||||
let config = buildAgent(source, model, mergedCategories, gitMasterConfig, browserProvider, disabledSkills)
|
||||
let config = buildAgent(source, model, mergedCategories)
|
||||
|
||||
// Apply resolved variant from model fallback chain
|
||||
if (resolvedVariant) {
|
||||
@@ -104,6 +105,7 @@ export function collectPendingBuiltinAgents(input: {
|
||||
}
|
||||
|
||||
config = applyOverrides(config, override, mergedCategories, directory)
|
||||
config = resolveAgentSkills(config, { gitMasterConfig, browserProvider, disabledSkills })
|
||||
|
||||
// Store for later - will be added after sisyphus and hephaestus
|
||||
pendingAgentConfigs.set(name, config)
|
||||
|
||||
@@ -138,7 +138,10 @@ export type OverridableAgentName = "build" | BuiltinAgentName;
|
||||
export type AgentName = BuiltinAgentName;
|
||||
|
||||
export type AgentOverrideConfig = Partial<AgentConfig> & {
|
||||
category?: string;
|
||||
prompt_append?: string;
|
||||
skills?: string[];
|
||||
tools?: Record<string, boolean>;
|
||||
variant?: string;
|
||||
fallback_models?: string | (string | import("../config/schema/fallback-models").FallbackModelObject)[];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user