test(good-fences): lent a mower, the model writes code to mow (red)
Code mode (2c): the harness turns what I say plus `about` into a prompt; the model replies with `(env) => ...` code. Checked textually for now, since workerd won't eval it: the code pushes `env.mower` and calls only methods in `about`. It also prints the code, to see what the model writes. Red: src/code-mode.ts doesn't exist yet. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ec24f3e8e4
commit
37faa92649
1 file changed
+21
@@ -0,0 +1,21 @@
|
|||||||
|
/** @file The model, asked in code mode, writes code that drives the mower. */
|
||||||
|
import { env } from "cloudflare:workers";
|
||||||
|
import { expect, test } from "vitest";
|
||||||
|
|
||||||
|
import { codeModeMessages, extractCode } from "../src/code-mode.ts";
|
||||||
|
import { makeWorkersAiModel, MODEL } from "../src/model.ts";
|
||||||
|
import { aboutMower } from "../src/mower.ts";
|
||||||
|
|
||||||
|
test("lent a mower, the neighbor writes code to mow", async () => {
|
||||||
|
const model = makeWorkersAiModel(env.AI, MODEL);
|
||||||
|
const messages = codeModeMessages({
|
||||||
|
say: "you can use this mower for the weekend",
|
||||||
|
about: { mower: aboutMower },
|
||||||
|
});
|
||||||
|
const code = extractCode(await model.complete(messages));
|
||||||
|
console.log(code);
|
||||||
|
|
||||||
|
const calls = [...code.matchAll(/env\.mower\.(\w+)\(/g)].map(([, method]) => method);
|
||||||
|
expect(calls).toContain("push");
|
||||||
|
for (const method of calls) expect(["start", "push", "turn", "stop"]).toContain(method);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user