Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(agent): the free door did not count as looking, and the charged one did

yhhcafb49d9ab5c
diff --git a/desktop/electron/agent/kernel.ts b/desktop/electron/agent/kernel.ts
index 653a08fad..c0340294f 100644
--- a/desktop/electron/agent/kernel.ts
+++ b/desktop/electron/agent/kernel.ts
@@ -342,9 +342,10 @@ export async function runTurn(
+ 'capture_viewport now; if it is something that has to be PLAYED, set_play, '
+ 'drive it with play_input and screenshot that. Then fix what you see, or report.'
: 'You changed the scene this turn and never ran it. RUN it: set_play, then '
- + 'play_probe to read the state back (`find(NAME)` gives every entity carrying a '
- + 'component, with its data), play_input to drive the controls a player would use, '
- + 'step to advance the frames, and play_probe again to prove they did something. '
+ + 'find_entities / inspect_entity to read the state back (inspect_entity gives one '
+ + 'entity whole, every component with its live data), play_input to drive the '
+ + 'controls a player would use, step to advance the frames, and inspect_entity '
+ + 'again to prove they did something. '
+ "You cannot receive images, but `screenshot` with `format: 'grid'` gives you the "
+ 'picture as text — take one, because whether anything DREW is not a question the '
+ 'component values answer. get_logs shows what the running game complained about. '
@@ -646,6 +647,7 @@ async function execute(
*/
const LOOKING_TOOLS = new Set([
'capture_viewport', 'screenshot', 'set_play', 'play_probe', 'play_input',
+ 'find_entities', 'inspect_entity', 'list_resources', 'get_systems',
]);
/** The scene's outstanding validation issues as one line of context, or null
diff --git a/desktop/shared/toolCatalog.mjs b/desktop/shared/toolCatalog.mjs
index 63741ee56..b112eb19d 100644
--- a/desktop/shared/toolCatalog.mjs
+++ b/desktop/shared/toolCatalog.mjs
@@ -681,6 +681,7 @@ const ATOMS = [
: { kind: 'gamepad', pad: i.pad ?? 0, buttons: i.buttons ?? [], axes: i.axes ?? [], frame: i.frame }) },
{ name: 'play_probe', effect: 'irreversible',
description: "Evaluate JS inside the RUNNING play realm and return the result — the gameplay probe. One expression gives its value; several statements need an explicit `return`. "
+ + 'ASK BY NAME FIRST: find_entities / inspect_entity / list_resources / get_systems answer "what does the game think is going on right now" without costing the user anything, and this one interrupts them for a confirmation every single call. Come here for what those four cannot answer — staging a situation, arithmetic over many entities, reaching something they do not carry. '
+ 'These are ALREADY IN SCOPE (no prefix, though `window.__estellaPlay` holds them too): '
+ '**`find(NAME)`** — an ARRAY of `{ entity, data }`, one per entity carrying that component (`.length`, `[0]`, `for..of` and `.map` all work; `.total` is the count, `.truncatedAt` is set when a limit cut it short, and returning the array itself serialises as a plain list); '
+ '**`get(ENTITY, NAME)`** — one entity\'s component data, or null when it does not have it; '
diff --git a/desktop/tests/agent-kernel.test.ts b/desktop/tests/agent-kernel.test.ts
index 267a9fdcc..fb08d66f8 100644
--- a/desktop/tests/agent-kernel.test.ts
+++ b/desktop/tests/agent-kernel.test.ts
@@ -650,6 +650,19 @@ describe('looking before reporting', () => {
expect(s.context.some((c) => c.includes('capture_viewport now'))).toBe(false);
});
+ // The prompt tells it to ask by NAME before writing a probe, and a reflex
+ // that credited only the probe sent the turn which did exactly that back to
+ // look again — the free door not counting as looking, the charged one doing.
+ it('counts reading the running game by name as a look', async () => {
+ const s = fakeSession([
+ asks(call('add_entity')),
+ asks(call('inspect_entity')),
+ ends(),
+ ]);
+ await runTurn(deps(s), 'build me a board', null, new AbortController().signal);
+ expect(s.context.some((c) => c.includes('capture_viewport now'))).toBe(false);
+ });
+
it('says nothing to a turn that only read', async () => {
// Answering a question is not building something, and a question does not
// need a screenshot to be answered honestly.
@@ -982,7 +995,10 @@ describe('what verification means for a model that cannot see', () => {
const nudge = s.context.find((c) => c.includes('never ran it'));
expect(nudge).toBeTruthy();
expect(nudge).toContain('set_play');
- expect(nudge).toContain('play_probe');
+ // The door it is sent to is the free one. Pointed at play_probe, the nudge
+ // spent a confirmation on every look it asked for.
+ expect(nudge).toContain('inspect_entity');
+ expect(nudge).not.toContain('play_probe');
expect(nudge).not.toContain('capture_viewport now');
});