refactor(core): own the execute tool description
This commit is contained in:
@@ -120,13 +120,6 @@ export type Runtime<R = never> = {
|
||||
readonly execute: (code: string) => Effect.Effect<Result, never, R>
|
||||
}
|
||||
|
||||
export const description = [
|
||||
"Run JavaScript in a confined Code Mode runtime through { code }.",
|
||||
"Call Code Mode tools through `tools` using the exact paths and signatures from the instructions.",
|
||||
"Use `search({ query })` to discover exact signatures when needed.",
|
||||
"Await important calls and use `Promise.all` for independent calls.",
|
||||
].join("\n")
|
||||
|
||||
const validateLimit = (name: keyof ExecutionLimits, value: number | undefined, minimum: number): number | undefined => {
|
||||
if (value !== undefined && (!Number.isSafeInteger(value) || value < minimum)) {
|
||||
throw new RangeError(`${name} must be a safe integer greater than or equal to ${minimum}.`)
|
||||
|
||||
@@ -550,23 +550,6 @@ describe("CodeMode schema flexibility", () => {
|
||||
})
|
||||
|
||||
describe("CodeMode public contract", () => {
|
||||
test("keeps the tool description independent from the catalog", () => {
|
||||
const runtime = CodeMode.make({
|
||||
tools: {
|
||||
lookup: Tool.make({
|
||||
description: "Look up a record",
|
||||
input: Schema.Struct({}),
|
||||
output: Schema.String,
|
||||
run: () => Effect.succeed("found"),
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
expect(CodeMode.description).toContain("confined Code Mode runtime")
|
||||
expect(CodeMode.description).not.toContain("lookup")
|
||||
expect(runtime.instructions()).toContain("tools.lookup(input:")
|
||||
})
|
||||
|
||||
const lookup = Tool.make({
|
||||
description: "Look up an order by ID",
|
||||
input: Schema.Struct({ id: Schema.String }),
|
||||
|
||||
@@ -42,9 +42,17 @@ export interface Registration {
|
||||
readonly namespace?: string
|
||||
}
|
||||
|
||||
// Invariant model-facing guidance; the changing tool catalog is delivered through Instructions.
|
||||
const description = [
|
||||
"Run JavaScript in a confined Code Mode runtime through { code }.",
|
||||
"Call Code Mode tools through `tools` using the exact paths and signatures from the instructions.",
|
||||
"Use `search({ query })` to discover exact signatures when needed.",
|
||||
"Await important calls and use `Promise.all` for independent calls.",
|
||||
].join("\n")
|
||||
|
||||
export const create = (registrations: ReadonlyMap<string, Registration>) => {
|
||||
return make({
|
||||
description: CodeMode.description,
|
||||
description,
|
||||
input: CodeMode.Input,
|
||||
output: ExecuteOutput,
|
||||
structured: ExecuteMetadata,
|
||||
|
||||
Reference in New Issue
Block a user