refactor(opencode): reuse deferred MCP resolution
This commit is contained in:
parent
0bff5bf389
commit
c2d619741b
4 changed files with 30 additions and 46 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue