fix(start-work): reuse registered opencode agent names
This commit is contained in:
@@ -5,7 +5,7 @@ import { injectContinuation } from "./continuation-injection"
|
||||
import { OMO_INTERNAL_INITIATOR_MARKER } from "../../shared/internal-initiator-marker"
|
||||
|
||||
describe("injectContinuation", () => {
|
||||
test("normalizes built-in display names to config keys before promptAsync", async () => {
|
||||
test("preserves the registered built-in agent name before promptAsync", async () => {
|
||||
// given
|
||||
let capturedAgent: string | undefined
|
||||
const ctx = {
|
||||
@@ -40,7 +40,7 @@ describe("injectContinuation", () => {
|
||||
})
|
||||
|
||||
// then
|
||||
expect(capturedAgent).toBe("sisyphus")
|
||||
expect(capturedAgent).toBe("Sisyphus - Ultraworker")
|
||||
})
|
||||
|
||||
test("inherits tools from resolved message info when reinjecting", async () => {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import type { PluginInput } from "@opencode-ai/plugin"
|
||||
|
||||
import type { BackgroundManager } from "../../features/background-agent"
|
||||
import { getSessionAgent } from "../../features/claude-code-session-state"
|
||||
import {
|
||||
getSessionAgent,
|
||||
resolveRegisteredAgentName,
|
||||
} from "../../features/claude-code-session-state"
|
||||
import {
|
||||
createInternalAgentTextPart,
|
||||
normalizeSDKResponse,
|
||||
@@ -127,6 +130,7 @@ export async function injectContinuation(args: {
|
||||
}
|
||||
|
||||
const promptAgent = normalizeAgentForPromptKey(agentName)
|
||||
const launchAgent = resolveRegisteredAgentName(agentName)
|
||||
|
||||
if (promptAgent && skipAgents.some(s => getAgentConfigKey(s) === getAgentConfigKey(promptAgent))) {
|
||||
log(`[${HOOK_NAME}] Skipped: agent in skipAgents list`, { sessionID, agent: agentName })
|
||||
@@ -168,7 +172,7 @@ ${todoList}`
|
||||
try {
|
||||
log(`[${HOOK_NAME}] Injecting continuation`, {
|
||||
sessionID,
|
||||
agent: promptAgent,
|
||||
agent: launchAgent ?? promptAgent,
|
||||
model,
|
||||
incompleteCount: freshIncompleteCount,
|
||||
})
|
||||
@@ -183,7 +187,7 @@ ${todoList}`
|
||||
await ctx.client.session.promptAsync({
|
||||
path: { id: sessionID },
|
||||
body: {
|
||||
agent: promptAgent,
|
||||
agent: launchAgent ?? promptAgent,
|
||||
...(launchModel ? { model: launchModel } : {}),
|
||||
...(launchVariant ? { variant: launchVariant } : {}),
|
||||
...(inheritedTools ? { tools: inheritedTools } : {}),
|
||||
|
||||
Reference in New Issue
Block a user