refactor(opencode): reuse deferred MCP resolution

This commit is contained in:
Aiden Cline 2026-06-29 07:59:55 -05:00
commit c2d619741b
4 changed files with 30 additions and 46 deletions

View file

@ -132,7 +132,7 @@ const belowThresholdIt = makeIt({
queryDescription: "Natural language analytics query",
})
function resolveTools(input: { messages?: SessionV1.WithParts[]; canDeferMcpTools?: boolean } = {}) {
function resolveToolResult(input: { messages?: SessionV1.WithParts[]; canDeferMcpTools?: boolean } = {}) {
return SessionTools.resolve({
agent,
model,
@ -145,6 +145,10 @@ function resolveTools(input: { messages?: SessionV1.WithParts[]; canDeferMcpTool
})
}
function resolveTools(input: { messages?: SessionV1.WithParts[]; canDeferMcpTools?: boolean } = {}) {
return resolveToolResult(input).pipe(Effect.map((result) => result.tools))
}
describe("session.tools", () => {
deferredIt.instance("defers MCP tools behind fixed search and call tools", () =>
Effect.gen(function* () {
@ -181,7 +185,7 @@ describe("session.tools", () => {
deferredIt.instance("lists deferred MCP servers in the system prompt", () =>
Effect.gen(function* () {
const prompt = yield* SessionTools.deferredSystemPrompt({ agent, session, messages: [] })
const prompt = (yield* resolveToolResult()).deferredSystemPrompt
expect(prompt).toContain("Deferred MCP servers available through `search_deferred_tools`:")
expect(prompt).toContain("- posthog: 2 tools")