.
This commit is contained in:
parent
7266b48ca0
commit
4f8ff6ab53
3 changed files with 20 additions and 6 deletions
|
|
@ -207,11 +207,7 @@ const live: Layer.Layer<
|
||||||
input.model.providerID.toLowerCase().includes("litellm") ||
|
input.model.providerID.toLowerCase().includes("litellm") ||
|
||||||
input.model.api.id.toLowerCase().includes("litellm")
|
input.model.api.id.toLowerCase().includes("litellm")
|
||||||
|
|
||||||
const repair = (toolName: string) => {
|
const repair = (toolName: string) => repairToolName(toolName, tools)
|
||||||
const next = toolName.toLowerCase()
|
|
||||||
if (!tools[next]) return
|
|
||||||
return next
|
|
||||||
}
|
|
||||||
|
|
||||||
// LiteLLM/Bedrock rejects requests where the message history contains tool
|
// LiteLLM/Bedrock rejects requests where the message history contains tool
|
||||||
// calls but no tools param is present. When there are no active tools (e.g.
|
// calls but no tools param is present. When there are no active tools (e.g.
|
||||||
|
|
@ -449,6 +445,12 @@ export const defaultLayer = Layer.suspend(() =>
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
export function repairToolName(toolName: string, tools: Record<string, Tool>) {
|
||||||
|
const next = ShellToolID.normalize(toolName.toLowerCase())
|
||||||
|
if (!tools[next]) return
|
||||||
|
return next
|
||||||
|
}
|
||||||
|
|
||||||
function resolveTools(input: Pick<StreamInput, "tools" | "agent" | "permission" | "user">) {
|
function resolveTools(input: Pick<StreamInput, "tools" | "agent" | "permission" | "user">) {
|
||||||
const disabled = Permission.disabled(
|
const disabled = Permission.disabled(
|
||||||
Object.keys(input.tools),
|
Object.keys(input.tools),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { afterAll, beforeAll, beforeEach, describe, expect, test } from "bun:test"
|
import { afterAll, beforeAll, beforeEach, describe, expect, test } from "bun:test"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { tool, type ModelMessage } from "ai"
|
import { tool, type ModelMessage, type Tool } from "ai"
|
||||||
import { Cause, Effect, Exit, Stream } from "effect"
|
import { Cause, Effect, Exit, Stream } from "effect"
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { makeRuntime } from "../../src/effect/run-service"
|
import { makeRuntime } from "../../src/effect/run-service"
|
||||||
|
|
@ -119,6 +119,17 @@ describe("session.llm.hasToolCalls", () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("session.llm.repairToolName", () => {
|
||||||
|
test("normalizes legacy bash alias to shell when available", () => {
|
||||||
|
expect(LLM.repairToolName("bash", { shell: {} as Tool })).toBe("shell")
|
||||||
|
expect(LLM.repairToolName("BASH", { shell: {} as Tool })).toBe("shell")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("returns undefined when normalized tool is unavailable", () => {
|
||||||
|
expect(LLM.repairToolName("bash", { read: {} as Tool })).toBeUndefined()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
type Capture = {
|
type Capture = {
|
||||||
url: URL
|
url: URL
|
||||||
headers: Headers
|
headers: Headers
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ export function ToolErrorCard(props: ToolErrorCardProps) {
|
||||||
webfetch: "ui.tool.webfetch",
|
webfetch: "ui.tool.webfetch",
|
||||||
websearch: "ui.tool.websearch",
|
websearch: "ui.tool.websearch",
|
||||||
codesearch: "ui.tool.codesearch",
|
codesearch: "ui.tool.codesearch",
|
||||||
|
bash: "ui.tool.shell",
|
||||||
shell: "ui.tool.shell",
|
shell: "ui.tool.shell",
|
||||||
apply_patch: "ui.tool.patch",
|
apply_patch: "ui.tool.patch",
|
||||||
question: "ui.tool.questions",
|
question: "ui.tool.questions",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue