Bug
generateTypeDefinitions in src/backends.ts tells the LLM to call tools using flat function syntax:
declare function fetch_fetch(args: FetchInput): Promise<any>;
But wrapCodeWithBindings in src/executor.ts only generates namespace objects, not flat functions:
const fetch = {
fetch: (args) => SecureExec.bindings.callTool("fetch_fetch", args || {})
};
So the LLM writes await fetch_fetch({url: ...}) based on the type hints, but the sandbox throws ReferenceError: fetch_fetch is not defined at runtime. The correct call is await fetch.fetch({url: ...}).
Impact
Every LLM using the type definitions will call tools incorrectly.
Fix
Two options:
Option A — also generate flat aliases in the sandbox wrapper (minimal change, keeps flat-call ergonomics):
// after generating namespace object, add flat aliases
for (const toolName of tools) {
const camelName = snakeToCamel(sanitizeName(toolName));
const flatName = `${sanitizeName(backendName)}_${sanitizeName(toolName)}`;
aliases.push(`const ${flatName} = ${sanitizeName(backendName)}.${camelName};`);
}
This makes both fetch.fetch({...}) and fetch_fetch({...}) work.
Option B — change generateTypeDefinitions to emit namespace-style declarations:
declare const fetch: {
fetch(args: FetchInput): Promise<any>; // Fetch a URL
};
Option A is the path of least resistance since it matches what the type hints already say.
Bug
generateTypeDefinitionsinsrc/backends.tstells the LLM to call tools using flat function syntax:But
wrapCodeWithBindingsinsrc/executor.tsonly generates namespace objects, not flat functions:So the LLM writes
await fetch_fetch({url: ...})based on the type hints, but the sandbox throwsReferenceError: fetch_fetch is not definedat runtime. The correct call isawait fetch.fetch({url: ...}).Impact
Every LLM using the type definitions will call tools incorrectly.
Fix
Two options:
Option A — also generate flat aliases in the sandbox wrapper (minimal change, keeps flat-call ergonomics):
This makes both
fetch.fetch({...})andfetch_fetch({...})work.Option B — change
generateTypeDefinitionsto emit namespace-style declarations:Option A is the path of least resistance since it matches what the type hints already say.