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:
@@ -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)
|
||||
|
||||
// then
|
||||
expect(args.subagent_type).toBe("sisyphus-junior")
|
||||
expect(args.subagent_type).toBe("Sisyphus-Junior")
|
||||
}, { timeout: 10000 })
|
||||
|
||||
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)
|
||||
|
||||
//#then
|
||||
expect(args.subagent_type).toBe("sisyphus-junior")
|
||||
expect(args.subagent_type).toBe("Sisyphus-Junior")
|
||||
expect(result).toContain("Background task launched")
|
||||
}, { timeout: 10000 })
|
||||
|
||||
@@ -3718,7 +3718,7 @@ describe("sisyphus-task", () => {
|
||||
)
|
||||
|
||||
// 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 })
|
||||
|
||||
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 type { DelegateTaskArgs, ToolContextWithMetadata, DelegateTaskToolOptions } from "./types"
|
||||
import { CATEGORY_DESCRIPTIONS } from "./constants"
|
||||
import { SISYPHUS_JUNIOR_AGENT } from "./sisyphus-junior-agent"
|
||||
import { mergeCategories } from "../../shared/merge-categories"
|
||||
import { log } from "../../shared/logger"
|
||||
import { buildSystemContent } from "./prompt-builder"
|
||||
@@ -88,13 +89,13 @@ Prompts MUST be in English.`
|
||||
const ctx = toolContext as ToolContextWithMetadata
|
||||
|
||||
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", {
|
||||
category: args.category,
|
||||
subagent_type: args.subagent_type,
|
||||
})
|
||||
}
|
||||
args.subagent_type = "sisyphus-junior"
|
||||
args.subagent_type = SISYPHUS_JUNIOR_AGENT
|
||||
}
|
||||
await ctx.metadata?.({
|
||||
title: args.description,
|
||||
|
||||
Reference in New Issue
Block a user