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 { AgentConfig } from "@opencode-ai/sdk"
|
||||||
import type { AgentFactory } from "./types"
|
import type { AgentFactory } from "./types"
|
||||||
import type { CategoriesConfig, CategoryConfig, GitMasterConfig } from "../config/schema"
|
import type { CategoriesConfig, CategoryConfig } from "../config/schema"
|
||||||
import type { BrowserAutomationProvider } from "../config/schema"
|
|
||||||
import { mergeCategories } from "../shared/merge-categories"
|
import { mergeCategories } from "../shared/merge-categories"
|
||||||
import { resolveMultipleSkills } from "../features/opencode-skill-loader/skill-content"
|
|
||||||
|
|
||||||
export type AgentSource = AgentFactory | AgentConfig
|
export type AgentSource = AgentFactory | AgentConfig
|
||||||
|
|
||||||
@@ -14,10 +12,7 @@ export function isFactory(source: AgentSource): source is AgentFactory {
|
|||||||
export function buildAgent(
|
export function buildAgent(
|
||||||
source: AgentSource,
|
source: AgentSource,
|
||||||
model: string,
|
model: string,
|
||||||
categories?: CategoriesConfig,
|
categories?: CategoriesConfig
|
||||||
gitMasterConfig?: GitMasterConfig,
|
|
||||||
browserProvider?: BrowserAutomationProvider,
|
|
||||||
disabledSkills?: Set<string>
|
|
||||||
): AgentConfig {
|
): AgentConfig {
|
||||||
const base = isFactory(source) ? source(model) : { ...source }
|
const base = isFactory(source) ? source(model) : { ...source }
|
||||||
const categoryConfigs: Record<string, CategoryConfig> = mergeCategories(categories)
|
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
|
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 type { AvailableAgent } from "../dynamic-agent-prompt-builder"
|
||||||
import { AGENT_MODEL_REQUIREMENTS, isModelAvailable } from "../../shared"
|
import { AGENT_MODEL_REQUIREMENTS, isModelAvailable } from "../../shared"
|
||||||
import { buildAgent, isFactory } from "../agent-builder"
|
import { buildAgent, isFactory } from "../agent-builder"
|
||||||
|
import { resolveAgentSkills } from "../agent-skill-resolution"
|
||||||
import { applyOverrides } from "./agent-overrides"
|
import { applyOverrides } from "./agent-overrides"
|
||||||
import { applyEnvironmentContext } from "./environment-context"
|
import { applyEnvironmentContext } from "./environment-context"
|
||||||
import { applyModelResolution, getFirstFallbackModel } from "./model-resolution"
|
import { applyModelResolution, getFirstFallbackModel } from "./model-resolution"
|
||||||
@@ -92,7 +93,7 @@ export function collectPendingBuiltinAgents(input: {
|
|||||||
if (!resolution) continue
|
if (!resolution) continue
|
||||||
const { model, variant: resolvedVariant } = resolution
|
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
|
// Apply resolved variant from model fallback chain
|
||||||
if (resolvedVariant) {
|
if (resolvedVariant) {
|
||||||
@@ -104,6 +105,7 @@ export function collectPendingBuiltinAgents(input: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config = applyOverrides(config, override, mergedCategories, directory)
|
config = applyOverrides(config, override, mergedCategories, directory)
|
||||||
|
config = resolveAgentSkills(config, { gitMasterConfig, browserProvider, disabledSkills })
|
||||||
|
|
||||||
// Store for later - will be added after sisyphus and hephaestus
|
// Store for later - will be added after sisyphus and hephaestus
|
||||||
pendingAgentConfigs.set(name, config)
|
pendingAgentConfigs.set(name, config)
|
||||||
|
|||||||
@@ -138,7 +138,10 @@ export type OverridableAgentName = "build" | BuiltinAgentName;
|
|||||||
export type AgentName = BuiltinAgentName;
|
export type AgentName = BuiltinAgentName;
|
||||||
|
|
||||||
export type AgentOverrideConfig = Partial<AgentConfig> & {
|
export type AgentOverrideConfig = Partial<AgentConfig> & {
|
||||||
|
category?: string;
|
||||||
prompt_append?: string;
|
prompt_append?: string;
|
||||||
|
skills?: string[];
|
||||||
|
tools?: Record<string, boolean>;
|
||||||
variant?: string;
|
variant?: string;
|
||||||
fallback_models?: string | (string | import("../config/schema/fallback-models").FallbackModelObject)[];
|
fallback_models?: string | (string | import("../config/schema/fallback-models").FallbackModelObject)[];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user