fix(run): inherit main-session tool permissions for continuation prompts

This commit is contained in:
YeonGyu-Kim
2026-02-18 18:02:42 +09:00
parent 80bb262066
commit dba7a1e07c
17 changed files with 297 additions and 28 deletions
@@ -0,0 +1,41 @@
declare const require: (name: string) => any
const { describe, expect, test } = require("bun:test")
import { injectContinuation } from "./continuation-injection"
describe("injectContinuation", () => {
test("inherits tools from resolved message info when reinjecting", async () => {
// given
let capturedTools: Record<string, boolean> | undefined
const ctx = {
directory: "/tmp/test",
client: {
session: {
todo: async () => ({ data: [{ id: "1", content: "todo", status: "pending", priority: "high" }] }),
promptAsync: async (input: { body: { tools?: Record<string, boolean> } }) => {
capturedTools = input.body.tools
return {}
},
},
},
}
const sessionStateStore = {
getExistingState: () => ({ inFlight: false, lastInjectedAt: 0, consecutiveFailures: 0 }),
}
// when
await injectContinuation({
ctx: ctx as never,
sessionID: "ses_continuation_tools",
resolvedInfo: {
agent: "Hephaestus",
model: { providerID: "openai", modelID: "gpt-5.3-codex" },
tools: { question: "deny", bash: "allow" },
},
sessionStateStore: sessionStateStore as never,
})
// then
expect(capturedTools).toEqual({ question: false, bash: true })
})
})
@@ -1,7 +1,7 @@
import type { PluginInput } from "@opencode-ai/plugin"
import type { BackgroundManager } from "../../features/background-agent"
import { normalizeSDKResponse } from "../../shared"
import { normalizeSDKResponse, resolveInheritedPromptTools } from "../../shared"
import {
findNearestMessageWithFields,
findNearestMessageWithFieldsFromSDK,
@@ -136,11 +136,14 @@ ${todoList}`
incompleteCount: freshIncompleteCount,
})
const inheritedTools = resolveInheritedPromptTools(sessionID, tools)
await ctx.client.session.promptAsync({
path: { id: sessionID },
body: {
agent: agentName,
...(model !== undefined ? { model } : {}),
...(inheritedTools ? { tools: inheritedTools } : {}),
parts: [{ type: "text", text: prompt }],
},
query: { directory: ctx.directory },