Merge pull request #1289 from KonaEspresso94/fix/agent-tools-bug
fix: honor tools overrides via permission migration
This commit is contained in:
commit
b7b466f4f2
0
bin/oh-my-opencode.js
Normal file → Executable file
0
bin/oh-my-opencode.js
Normal file → Executable file
@ -740,6 +740,52 @@ describe("override.category expansion in createBuiltinAgents", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("agent override tools migration", () => {
|
||||||
|
test("tools: { x: false } is migrated to permission: { x: deny }", async () => {
|
||||||
|
// #given
|
||||||
|
const overrides = {
|
||||||
|
explore: { tools: { "jetbrains_*": false } } as any,
|
||||||
|
}
|
||||||
|
|
||||||
|
// #when
|
||||||
|
const agents = await createBuiltinAgents([], overrides, undefined, TEST_DEFAULT_MODEL)
|
||||||
|
|
||||||
|
// #then
|
||||||
|
expect(agents.explore).toBeDefined()
|
||||||
|
const permission = agents.explore.permission as Record<string, string>
|
||||||
|
expect(permission["jetbrains_*"]).toBe("deny")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("tools: { x: true } is migrated to permission: { x: allow }", async () => {
|
||||||
|
// #given
|
||||||
|
const overrides = {
|
||||||
|
librarian: { tools: { "jetbrains_get_*": true } } as any,
|
||||||
|
}
|
||||||
|
|
||||||
|
// #when
|
||||||
|
const agents = await createBuiltinAgents([], overrides, undefined, TEST_DEFAULT_MODEL)
|
||||||
|
|
||||||
|
// #then
|
||||||
|
expect(agents.librarian).toBeDefined()
|
||||||
|
const permission = agents.librarian.permission as Record<string, string>
|
||||||
|
expect(permission["jetbrains_get_*"]).toBe("allow")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("tools config is removed after migration", async () => {
|
||||||
|
// #given
|
||||||
|
const overrides = {
|
||||||
|
explore: { tools: { "some_tool": false } } as any,
|
||||||
|
}
|
||||||
|
|
||||||
|
// #when
|
||||||
|
const agents = await createBuiltinAgents([], overrides, undefined, TEST_DEFAULT_MODEL)
|
||||||
|
|
||||||
|
// #then
|
||||||
|
expect(agents.explore).toBeDefined()
|
||||||
|
expect((agents.explore as any).tools).toBeUndefined()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("Deadlock prevention - fetchAvailableModels must not receive client", () => {
|
describe("Deadlock prevention - fetchAvailableModels must not receive client", () => {
|
||||||
test("createBuiltinAgents should call fetchAvailableModels with undefined client to prevent deadlock", async () => {
|
test("createBuiltinAgents should call fetchAvailableModels with undefined client to prevent deadlock", async () => {
|
||||||
// #given - This test ensures we don't regress on issue #1301
|
// #given - This test ensures we don't regress on issue #1301
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import { createAtlasAgent, atlasPromptMetadata } from "./atlas"
|
|||||||
import { createMomusAgent, momusPromptMetadata } from "./momus"
|
import { createMomusAgent, momusPromptMetadata } from "./momus"
|
||||||
import { createHephaestusAgent } from "./hephaestus"
|
import { createHephaestusAgent } from "./hephaestus"
|
||||||
import type { AvailableAgent, AvailableCategory, AvailableSkill } from "./dynamic-agent-prompt-builder"
|
import type { AvailableAgent, AvailableCategory, AvailableSkill } from "./dynamic-agent-prompt-builder"
|
||||||
import { deepMerge, fetchAvailableModels, resolveModelPipeline, AGENT_MODEL_REQUIREMENTS, readConnectedProvidersCache, isModelAvailable, isAnyFallbackModelAvailable } from "../shared"
|
import { deepMerge, fetchAvailableModels, resolveModelPipeline, AGENT_MODEL_REQUIREMENTS, readConnectedProvidersCache, isModelAvailable, isAnyFallbackModelAvailable, migrateAgentConfig } from "../shared"
|
||||||
import { DEFAULT_CATEGORIES, CATEGORY_DESCRIPTIONS } from "../tools/delegate-task/constants"
|
import { DEFAULT_CATEGORIES, CATEGORY_DESCRIPTIONS } from "../tools/delegate-task/constants"
|
||||||
import { resolveMultipleSkills } from "../features/opencode-skill-loader/skill-content"
|
import { resolveMultipleSkills } from "../features/opencode-skill-loader/skill-content"
|
||||||
import { createBuiltinSkills } from "../features/builtin-skills"
|
import { createBuiltinSkills } from "../features/builtin-skills"
|
||||||
@ -207,7 +207,8 @@ function mergeAgentConfig(
|
|||||||
base: AgentConfig,
|
base: AgentConfig,
|
||||||
override: AgentOverrideConfig
|
override: AgentOverrideConfig
|
||||||
): AgentConfig {
|
): AgentConfig {
|
||||||
const { prompt_append, ...rest } = override
|
const migratedOverride = migrateAgentConfig(override as Record<string, unknown>) as AgentOverrideConfig
|
||||||
|
const { prompt_append, ...rest } = migratedOverride
|
||||||
const merged = deepMerge(base, rest as Partial<AgentConfig>)
|
const merged = deepMerge(base, rest as Partial<AgentConfig>)
|
||||||
|
|
||||||
if (prompt_append && merged.prompt) {
|
if (prompt_append && merged.prompt) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user