fix: resolve category delegation and command routing with display name agent keys
Category-based delegation (task(category='quick')) was broken because
SISYPHUS_JUNIOR_AGENT sent 'sisyphus-junior' to session.prompt but
config.agent keys are now display names ('Sisyphus-Junior').
- Use getAgentDisplayName() for SISYPHUS_JUNIOR_AGENT constant
- Replace hardcoded 'sisyphus-junior' strings in tools.ts with constant
- Update background-output local constants to use display names
- Add remapCommandAgentFields() to translate command agent fields
- Add raw-key fallback in tool-config-handler agentByKey()
This commit is contained in:
parent
be2e45b4cb
commit
cb601ddd77
@ -1,4 +1,5 @@
|
|||||||
import type { OhMyOpenCodeConfig } from "../config";
|
import type { OhMyOpenCodeConfig } from "../config";
|
||||||
|
import { getAgentDisplayName } from "../shared/agent-display-names";
|
||||||
import {
|
import {
|
||||||
loadUserCommands,
|
loadUserCommands,
|
||||||
loadProjectCommands,
|
loadProjectCommands,
|
||||||
@ -68,4 +69,14 @@ export async function applyCommandConfig(params: {
|
|||||||
...params.pluginComponents.commands,
|
...params.pluginComponents.commands,
|
||||||
...params.pluginComponents.skills,
|
...params.pluginComponents.skills,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
remapCommandAgentFields(params.config.command as Record<string, Record<string, unknown>>);
|
||||||
|
}
|
||||||
|
|
||||||
|
function remapCommandAgentFields(commands: Record<string, Record<string, unknown>>): void {
|
||||||
|
for (const cmd of Object.values(commands)) {
|
||||||
|
if (cmd?.agent && typeof cmd.agent === "string") {
|
||||||
|
cmd.agent = getAgentDisplayName(cmd.agent);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,9 @@ import { getAgentDisplayName } from "../shared/agent-display-names";
|
|||||||
type AgentWithPermission = { permission?: Record<string, unknown> };
|
type AgentWithPermission = { permission?: Record<string, unknown> };
|
||||||
|
|
||||||
function agentByKey(agentResult: Record<string, unknown>, key: string): AgentWithPermission | undefined {
|
function agentByKey(agentResult: Record<string, unknown>, key: string): AgentWithPermission | undefined {
|
||||||
return agentResult[getAgentDisplayName(key)] as AgentWithPermission | undefined;
|
return (agentResult[key] ?? agentResult[getAgentDisplayName(key)]) as
|
||||||
|
| AgentWithPermission
|
||||||
|
| undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function applyToolConfig(params: {
|
export function applyToolConfig(params: {
|
||||||
|
|||||||
@ -9,7 +9,9 @@ import { formatFullSession } from "./full-session-format"
|
|||||||
import { formatTaskResult } from "./task-result-format"
|
import { formatTaskResult } from "./task-result-format"
|
||||||
import { formatTaskStatus } from "./task-status-format"
|
import { formatTaskStatus } from "./task-status-format"
|
||||||
|
|
||||||
const SISYPHUS_JUNIOR_AGENT = "sisyphus-junior"
|
import { getAgentDisplayName } from "../../shared/agent-display-names"
|
||||||
|
|
||||||
|
const SISYPHUS_JUNIOR_AGENT = getAgentDisplayName("sisyphus-junior")
|
||||||
|
|
||||||
type ToolContextWithMetadata = {
|
type ToolContextWithMetadata = {
|
||||||
sessionID: string
|
sessionID: string
|
||||||
|
|||||||
@ -8,7 +8,9 @@ import { storeToolMetadata } from "../../../features/tool-metadata-store"
|
|||||||
import type { BackgroundTask } from "../../../features/background-agent"
|
import type { BackgroundTask } from "../../../features/background-agent"
|
||||||
import type { ToolContextWithMetadata } from "./utils"
|
import type { ToolContextWithMetadata } from "./utils"
|
||||||
|
|
||||||
const SISYPHUS_JUNIOR_AGENT = "sisyphus-junior"
|
import { getAgentDisplayName } from "../../../shared/agent-display-names"
|
||||||
|
|
||||||
|
const SISYPHUS_JUNIOR_AGENT = getAgentDisplayName("sisyphus-junior")
|
||||||
|
|
||||||
type ToolContextWithCallId = ToolContextWithMetadata & {
|
type ToolContextWithCallId = ToolContextWithMetadata & {
|
||||||
callID?: string
|
callID?: string
|
||||||
|
|||||||
@ -85,7 +85,7 @@ describe("background_output full_session", () => {
|
|||||||
|
|
||||||
const task = createTask({
|
const task = createTask({
|
||||||
id: "task-1",
|
id: "task-1",
|
||||||
agent: "sisyphus-junior",
|
agent: "Sisyphus-Junior",
|
||||||
category: "quick",
|
category: "quick",
|
||||||
description: "Fix flaky test",
|
description: "Fix flaky test",
|
||||||
status: "running",
|
status: "running",
|
||||||
|
|||||||
@ -1 +1,3 @@
|
|||||||
export const SISYPHUS_JUNIOR_AGENT = "sisyphus-junior"
|
import { getAgentDisplayName } from "../../shared/agent-display-names"
|
||||||
|
|
||||||
|
export const SISYPHUS_JUNIOR_AGENT = getAgentDisplayName("sisyphus-junior")
|
||||||
|
|||||||
@ -452,7 +452,7 @@ describe("sisyphus-task", () => {
|
|||||||
await tool.execute(args, toolContext)
|
await tool.execute(args, toolContext)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(args.subagent_type).toBe("sisyphus-junior")
|
expect(args.subagent_type).toBe("Sisyphus-Junior")
|
||||||
}, { timeout: 10000 })
|
}, { timeout: 10000 })
|
||||||
|
|
||||||
test("category overrides subagent_type and still maps to sisyphus-junior", async () => {
|
test("category overrides subagent_type and still maps to sisyphus-junior", async () => {
|
||||||
@ -517,7 +517,7 @@ describe("sisyphus-task", () => {
|
|||||||
const result = await tool.execute(args, toolContext)
|
const result = await tool.execute(args, toolContext)
|
||||||
|
|
||||||
//#then
|
//#then
|
||||||
expect(args.subagent_type).toBe("sisyphus-junior")
|
expect(args.subagent_type).toBe("Sisyphus-Junior")
|
||||||
expect(result).toContain("Background task launched")
|
expect(result).toContain("Background task launched")
|
||||||
}, { timeout: 10000 })
|
}, { timeout: 10000 })
|
||||||
|
|
||||||
@ -3718,7 +3718,7 @@ describe("sisyphus-task", () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// then - title should follow OpenCode format
|
// then - title should follow OpenCode format
|
||||||
expect(createBody.title).toBe("Implement feature X (@sisyphus-junior subagent)")
|
expect(createBody.title).toBe("Implement feature X (@Sisyphus-Junior subagent)")
|
||||||
}, { timeout: 10000 })
|
}, { timeout: 10000 })
|
||||||
|
|
||||||
test("sync task output includes <task_metadata> block with session_id", async () => {
|
test("sync task output includes <task_metadata> block with session_id", async () => {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { tool, type ToolDefinition } from "@opencode-ai/plugin"
|
import { tool, type ToolDefinition } from "@opencode-ai/plugin"
|
||||||
import type { DelegateTaskArgs, ToolContextWithMetadata, DelegateTaskToolOptions } from "./types"
|
import type { DelegateTaskArgs, ToolContextWithMetadata, DelegateTaskToolOptions } from "./types"
|
||||||
import { CATEGORY_DESCRIPTIONS } from "./constants"
|
import { CATEGORY_DESCRIPTIONS } from "./constants"
|
||||||
|
import { SISYPHUS_JUNIOR_AGENT } from "./sisyphus-junior-agent"
|
||||||
import { mergeCategories } from "../../shared/merge-categories"
|
import { mergeCategories } from "../../shared/merge-categories"
|
||||||
import { log } from "../../shared/logger"
|
import { log } from "../../shared/logger"
|
||||||
import { buildSystemContent } from "./prompt-builder"
|
import { buildSystemContent } from "./prompt-builder"
|
||||||
@ -88,13 +89,13 @@ Prompts MUST be in English.`
|
|||||||
const ctx = toolContext as ToolContextWithMetadata
|
const ctx = toolContext as ToolContextWithMetadata
|
||||||
|
|
||||||
if (args.category) {
|
if (args.category) {
|
||||||
if (args.subagent_type && args.subagent_type !== "sisyphus-junior") {
|
if (args.subagent_type && args.subagent_type !== SISYPHUS_JUNIOR_AGENT) {
|
||||||
log("[task] category provided - overriding subagent_type to sisyphus-junior", {
|
log("[task] category provided - overriding subagent_type to sisyphus-junior", {
|
||||||
category: args.category,
|
category: args.category,
|
||||||
subagent_type: args.subagent_type,
|
subagent_type: args.subagent_type,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
args.subagent_type = "sisyphus-junior"
|
args.subagent_type = SISYPHUS_JUNIOR_AGENT
|
||||||
}
|
}
|
||||||
await ctx.metadata?.({
|
await ctx.metadata?.({
|
||||||
title: args.description,
|
title: args.description,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user