refactor(codemode): remove generic agent tool (#35420)
This commit is contained in:
parent
391aa38281
commit
f950497173
6 changed files with 23 additions and 67 deletions
|
|
@ -1,13 +1,6 @@
|
|||
import { describe, expect, test } from "bun:test"
|
||||
import { Cause, Effect, Schema } from "effect"
|
||||
import {
|
||||
CodeMode,
|
||||
ExecuteInputSchema,
|
||||
ExecuteResultSchema,
|
||||
Tool,
|
||||
toolError,
|
||||
type ExecutionLimits,
|
||||
} from "../src/index.js"
|
||||
import { CodeMode, Tool, toolError, type ExecutionLimits } from "../src/index.js"
|
||||
import type { Definition } from "../src/tool.js"
|
||||
|
||||
const run = (tool: Definition<never>) =>
|
||||
|
|
@ -235,7 +228,7 @@ describe("CodeMode console capture", () => {
|
|||
logs: ['Thread info: {"name":"Demo","count":2}', "[warn] careful"],
|
||||
toolCalls: [],
|
||||
})
|
||||
expect(Schema.decodeUnknownSync(ExecuteResultSchema)(JSON.parse(JSON.stringify(result)))).toStrictEqual(result)
|
||||
expect(Schema.decodeUnknownSync(CodeMode.Result)(JSON.parse(JSON.stringify(result)))).toStrictEqual(result)
|
||||
})
|
||||
|
||||
test("keeps logs captured before failures", async () => {
|
||||
|
|
@ -371,7 +364,7 @@ describe("CodeMode output budget", () => {
|
|||
expect(result.value).toMatch(
|
||||
/^\{"data":"x+ \[result truncated: \d+ bytes exceeds the 40-byte output limit; return a smaller value\]$/,
|
||||
)
|
||||
expect(Schema.decodeUnknownSync(ExecuteResultSchema)(JSON.parse(JSON.stringify(result)))).toStrictEqual(result)
|
||||
expect(Schema.decodeUnknownSync(CodeMode.Result)(JSON.parse(JSON.stringify(result)))).toStrictEqual(result)
|
||||
})
|
||||
|
||||
test("keeps leading logs within the remaining budget and marks the cut", async () => {
|
||||
|
|
@ -501,24 +494,16 @@ describe("CodeMode public contract", () => {
|
|||
const tools = { orders: { lookup } }
|
||||
const source = `return await tools.orders.lookup({ id: "order_42" })`
|
||||
|
||||
test("keeps one-shot, reusable, and agent-tool execution equivalent", async () => {
|
||||
test("keeps one-shot and reusable execution equivalent", async () => {
|
||||
const runtime = CodeMode.make({ tools })
|
||||
const agentTool = runtime.agentTool()
|
||||
const [oneShot, reusable, projected] = await Promise.all([
|
||||
const [oneShot, reusable] = await Promise.all([
|
||||
Effect.runPromise(CodeMode.execute({ tools, code: source })),
|
||||
Effect.runPromise(runtime.execute(source)),
|
||||
Effect.runPromise(agentTool.execute({ code: source })),
|
||||
])
|
||||
|
||||
expect(reusable).toStrictEqual(oneShot)
|
||||
expect(projected).toStrictEqual(oneShot)
|
||||
expect(agentTool.name).toBe("code")
|
||||
expect(agentTool.input).toBe(ExecuteInputSchema)
|
||||
expect(agentTool.output).toBe(ExecuteResultSchema)
|
||||
expect(agentTool.description).toBe(runtime.instructions())
|
||||
expect(Schema.decodeUnknownSync(ExecuteResultSchema)(JSON.parse(JSON.stringify(projected)))).toStrictEqual(
|
||||
projected,
|
||||
)
|
||||
expect(Schema.decodeUnknownSync(CodeMode.Input)({ code: source })).toStrictEqual({ code: source })
|
||||
expect(Schema.decodeUnknownSync(CodeMode.Result)(JSON.parse(JSON.stringify(reusable)))).toStrictEqual(reusable)
|
||||
})
|
||||
|
||||
test("inlines a COMPLETE small catalog and keeps search registered but unadvertised", async () => {
|
||||
|
|
@ -1035,7 +1020,7 @@ describe("CodeMode public contract", () => {
|
|||
value: { top: null, nested: [1, null] },
|
||||
toolCalls: [],
|
||||
})
|
||||
expect(Schema.decodeUnknownSync(ExecuteResultSchema)(JSON.parse(JSON.stringify(result)))).toStrictEqual(result)
|
||||
expect(Schema.decodeUnknownSync(CodeMode.Result)(JSON.parse(JSON.stringify(result)))).toStrictEqual(result)
|
||||
})
|
||||
|
||||
test("rejects invalid configuration and discovery limits", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue