fix(runtime-fallback): carry delegated system and tools through bootstrap retry

When the first prompt fails before any durable user message persists,
runtime fallback retry was rebuilding the request from parts alone and
losing the delegated agent system prompt and tool gates. Now it threads
bootstrap.system and bootstrap.tools into the retry body alongside the
captured retry parts, so the retried prompt keeps the same scope as the
initial delegate launch.
This commit is contained in:
YeonGyu-Kim
2026-05-17 00:08:30 +09:00
parent 761f682add
commit ba648685d4
4 changed files with 53 additions and 9 deletions
+18 -3
View File
@@ -8,6 +8,7 @@ import {
} from "../../shared/delegated-child-session-bootstrap"
import * as loggerModule from "../../shared/logger"
import { SessionCategoryRegistry } from "../../shared/session-category-registry"
import type { RuntimeFallbackPluginInput } from "./types"
type RuntimeFallbackModule = typeof import("./hook")
@@ -49,8 +50,8 @@ describe("runtime-fallback", () => {
abort?: (args: unknown) => Promise<unknown>
status?: () => Promise<unknown>
}
}) {
return unsafeTestValue({
}): RuntimeFallbackPluginInput {
return unsafeTestValue<RuntimeFallbackPluginInput>({
client: {
tui: {
showToast: async (opts: { body: { title: string; message: string; variant: string; duration: number } }) => {
@@ -522,6 +523,8 @@ describe("runtime-fallback", () => {
sessionID,
promptText: "inspect src/tools/delegate-task and report the issue",
category: "quick",
system: "delegated child system prompt",
tools: { call_omo_agent: true, question: false, task: false },
})
await hook.event({
@@ -538,14 +541,19 @@ describe("runtime-fallback", () => {
const promptBody = promptCalls[0]?.body as {
model?: { providerID?: string; modelID?: string }
parts?: Array<{ type?: string; text?: string }>
system?: string
tools?: Record<string, boolean>
variant?: string
} | undefined
expect(promptBody?.model).toEqual({ providerID: "openai", modelID: "gpt-5.4" })
expect(promptBody?.variant).toBe("high")
expect(promptBody?.system).toBe("delegated child system prompt")
expect(promptBody?.tools?.question).toBe(false)
expect(promptBody?.tools?.call_omo_agent).toBe(true)
expect(promptBody?.parts?.[0]?.text).toContain("inspect src/tools/delegate-task")
})
test("should discard delegated bootstrap once persisted user prompt exists", async () => {
test("should use persisted user prompt while preserving delegated bootstrap launch context", async () => {
const promptCalls: Array<Record<string, unknown>> = []
const sessionID = "test-delegated-history-prefers-persisted-user"
const hook = createRuntimeFallbackHook(
@@ -577,6 +585,8 @@ describe("runtime-fallback", () => {
registerDelegatedChildSessionBootstrap({
sessionID,
promptText: "bootstrap copy should not be reused",
system: "persisted delegated child system prompt",
tools: { call_omo_agent: true, question: false, task: false },
})
SessionCategoryRegistry.register(sessionID, "test")
@@ -593,8 +603,13 @@ describe("runtime-fallback", () => {
expect(promptCalls).toHaveLength(1)
const promptBody = promptCalls[0]?.body as {
parts?: Array<{ type?: string; text?: string }>
system?: string
tools?: Record<string, boolean>
} | undefined
expect(promptBody?.parts?.[0]?.text).toBe("persisted child task prompt")
expect(promptBody?.system).toBe("persisted delegated child system prompt")
expect(promptBody?.tools?.question).toBe(false)
expect(promptBody?.tools?.call_omo_agent).toBe(true)
expect(getDelegatedChildSessionBootstrap(sessionID)).toBeUndefined()
})