fix(core): omit unavailable host tools
This commit is contained in:
parent
8bb211ebfd
commit
7d79daa2ca
13 changed files with 179 additions and 86 deletions
|
|
@ -18,6 +18,13 @@ const registry = ToolRegistry.layer.pipe(
|
|||
Layer.provide(ToolOutputStore.defaultLayer),
|
||||
)
|
||||
const it = testEffect(Layer.mergeAll(applications, registry))
|
||||
const unavailableApplications = ApplicationTools.layerWithUnavailable(new Set(["question"]))
|
||||
const unavailableRegistry = ToolRegistry.layer.pipe(
|
||||
Layer.provide(permission),
|
||||
Layer.provide(unavailableApplications),
|
||||
Layer.provide(ToolOutputStore.defaultLayer),
|
||||
)
|
||||
const unavailableIt = testEffect(Layer.mergeAll(unavailableApplications, unavailableRegistry))
|
||||
|
||||
const sessionID = SessionV2.ID.make("ses_application_tool")
|
||||
const contextual = (contexts: Tool.Context[]) =>
|
||||
|
|
@ -186,4 +193,20 @@ describe("ApplicationTools", () => {
|
|||
expect(applicationContexts).toEqual([])
|
||||
}),
|
||||
)
|
||||
|
||||
unavailableIt.effect("omits and rejects tools the host cannot service", () =>
|
||||
Effect.gen(function* () {
|
||||
const registry = yield* ToolRegistry.Service
|
||||
const transform = yield* registry.transform()
|
||||
yield* transform((editor) => editor.set("question", { tool: contextual([]).definition }))
|
||||
|
||||
expect(yield* registry.definitions()).toEqual([])
|
||||
expect(
|
||||
yield* registry.execute({
|
||||
sessionID,
|
||||
call: { type: "tool-call", id: "call-stale-question", name: "question", input: { query: "Continue?" } },
|
||||
}),
|
||||
).toEqual({ type: "error", value: "Unknown tool: question" })
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue