mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
conformance/tools.ts records, next to valid, denied and failing calls, how a call with invalid input settles against other jobs, its message, the tool.before and tool.after hooks it runs (none), toolCalls (not listed) and max_tool_calls (not counted). tests/tool_input.rs replays it; CI regenerates it with the other recordings.
393 lines
8.7 KiB
JSON
393 lines
8.7 KiB
JSON
{
|
|
"cases": [
|
|
{
|
|
"code": "const log = []; const a = tools.t.typed({ id: 'x' }).then(() => log.push('a ok'), (e) => log.push('a rejected'))\n const b = tools.t.typed({ id: 1 }).then(() => log.push('b ok'))\n Promise.resolve().then(() => log.push('job 1')).then(() => log.push('job 2')).then(() => log.push('job 3')).then(() => log.push('job 4'))\n await Promise.all([a, b]); return log",
|
|
"outcome": {
|
|
"ok": true,
|
|
"value": [
|
|
"job 1",
|
|
"job 2",
|
|
"job 3",
|
|
"job 4",
|
|
"a rejected",
|
|
"b ok"
|
|
]
|
|
},
|
|
"toolCalls": [
|
|
"t.typed"
|
|
],
|
|
"log": [
|
|
[
|
|
"before",
|
|
"t.typed",
|
|
{
|
|
"id": 1
|
|
}
|
|
],
|
|
[
|
|
"run",
|
|
"t.typed",
|
|
1
|
|
],
|
|
[
|
|
"after",
|
|
"t.typed",
|
|
"success"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"code": "const log = []; const a = tools.t.echo(1, 2).catch(() => log.push('arity')); const b = tools.t.nope({}).catch(() => log.push('unknown'))\n const c = tools.t.fail({}).catch(() => log.push('failed')); Promise.resolve().then(() => log.push('job')).then(() => log.push('job 2'))\n await Promise.all([a, b, c]); return log",
|
|
"outcome": {
|
|
"ok": true,
|
|
"value": [
|
|
"job",
|
|
"job 2",
|
|
"arity",
|
|
"unknown",
|
|
"failed"
|
|
]
|
|
},
|
|
"toolCalls": [
|
|
"t.fail"
|
|
],
|
|
"log": [
|
|
[
|
|
"before",
|
|
"t.fail",
|
|
{}
|
|
],
|
|
[
|
|
"run",
|
|
"t.fail"
|
|
],
|
|
[
|
|
"after",
|
|
"t.fail",
|
|
"failure"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"code": "const m = (p) => p.then((v) => ['ok', v], (e) => [e.name, e.message])\n return [await m(tools.t.typed({ id: 'x' })), await m(tools.t.typed(1, 2)), await m(tools.t.typed()), await m(tools.t.typed({ id: 1, extra: 2 })),\n await m(tools.t.nope({})), await m(tools.zz.nope({})), await m(tools.t.echo({ deny: true })), await m(tools.t.fail({}))]",
|
|
"outcome": {
|
|
"ok": true,
|
|
"value": [
|
|
[
|
|
"Error",
|
|
"Invalid input for tool 't.typed': SchemaError(Expected number\n at [\"id\"])"
|
|
],
|
|
[
|
|
"Error",
|
|
"Tool 't.typed' expects at most one input object."
|
|
],
|
|
[
|
|
"Error",
|
|
"Invalid input for tool 't.typed': SchemaError(Missing key\n at [\"id\"])"
|
|
],
|
|
[
|
|
"ok",
|
|
1
|
|
],
|
|
[
|
|
"Error",
|
|
"Unknown tool 't.nope'."
|
|
],
|
|
[
|
|
"Error",
|
|
"Unknown tool 'zz.nope'."
|
|
],
|
|
[
|
|
"Error",
|
|
"denied"
|
|
],
|
|
[
|
|
"Error",
|
|
"boom"
|
|
]
|
|
]
|
|
},
|
|
"toolCalls": [
|
|
"t.typed",
|
|
"t.echo",
|
|
"t.fail"
|
|
],
|
|
"log": [
|
|
[
|
|
"before",
|
|
"t.typed",
|
|
{
|
|
"id": 1
|
|
}
|
|
],
|
|
[
|
|
"run",
|
|
"t.typed",
|
|
1
|
|
],
|
|
[
|
|
"after",
|
|
"t.typed",
|
|
"success"
|
|
],
|
|
[
|
|
"before",
|
|
"t.echo",
|
|
{
|
|
"deny": true
|
|
}
|
|
],
|
|
[
|
|
"before",
|
|
"t.fail",
|
|
{}
|
|
],
|
|
[
|
|
"run",
|
|
"t.fail"
|
|
],
|
|
[
|
|
"after",
|
|
"t.fail",
|
|
"failure"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"code": "const t = (f) => { try { return ['ok', f().items.length] } catch (e) { return [e.name, e.message] } }\n return [t(() => search({ limit: -1 })), t(() => search(1, 2)), t(() => search({ query: 5 })),\n await tools.search({ limit: 'x' }).then((r) => r.items.length, (e) => [e.name, e.message])]",
|
|
"outcome": {
|
|
"ok": true,
|
|
"value": [
|
|
[
|
|
"Error",
|
|
"Invalid input for tool 'search': SchemaError(Expected a value greater than 0\n at [\"limit\"])"
|
|
],
|
|
[
|
|
"Error",
|
|
"Tool 'search' expects at most one input object."
|
|
],
|
|
[
|
|
"Error",
|
|
"Invalid input for tool 'search': SchemaError(Expected string\n at [\"query\"])"
|
|
],
|
|
[
|
|
"Error",
|
|
"Invalid input for tool 'search': SchemaError(Expected number\n at [\"limit\"])"
|
|
]
|
|
]
|
|
},
|
|
"toolCalls": [],
|
|
"log": []
|
|
},
|
|
{
|
|
"code": "await tools.t.typed({ id: 1 }); await tools.t.typed({ id: 'x' }).catch(() => 0); await tools.t.echo({ deny: true }).catch(() => 0); await tools.t.fail({}).catch(() => 0); return 1",
|
|
"outcome": {
|
|
"ok": true,
|
|
"value": 1
|
|
},
|
|
"toolCalls": [
|
|
"t.typed",
|
|
"t.echo",
|
|
"t.fail"
|
|
],
|
|
"log": [
|
|
[
|
|
"before",
|
|
"t.typed",
|
|
{
|
|
"id": 1
|
|
}
|
|
],
|
|
[
|
|
"run",
|
|
"t.typed",
|
|
1
|
|
],
|
|
[
|
|
"after",
|
|
"t.typed",
|
|
"success"
|
|
],
|
|
[
|
|
"before",
|
|
"t.echo",
|
|
{
|
|
"deny": true
|
|
}
|
|
],
|
|
[
|
|
"before",
|
|
"t.fail",
|
|
{}
|
|
],
|
|
[
|
|
"run",
|
|
"t.fail"
|
|
],
|
|
[
|
|
"after",
|
|
"t.fail",
|
|
"failure"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"code": "const r = []; for (const input of [{ id: 'x' }, { id: 1 }, { id: 'y' }, { id: 2 }, { id: 3 }]) r.push(await tools.t.typed(input).then((v) => v, (e) => [e.name, e.message])); return r",
|
|
"maxToolCalls": 2,
|
|
"outcome": {
|
|
"ok": true,
|
|
"value": [
|
|
[
|
|
"Error",
|
|
"Invalid input for tool 't.typed': SchemaError(Expected number\n at [\"id\"])"
|
|
],
|
|
1,
|
|
[
|
|
"Error",
|
|
"Invalid input for tool 't.typed': SchemaError(Expected number\n at [\"id\"])"
|
|
],
|
|
2,
|
|
[
|
|
"Error",
|
|
"Execution exceeded its tool-call limit of 2."
|
|
]
|
|
]
|
|
},
|
|
"toolCalls": [
|
|
"t.typed",
|
|
"t.typed"
|
|
],
|
|
"log": [
|
|
[
|
|
"before",
|
|
"t.typed",
|
|
{
|
|
"id": 1
|
|
}
|
|
],
|
|
[
|
|
"run",
|
|
"t.typed",
|
|
1
|
|
],
|
|
[
|
|
"after",
|
|
"t.typed",
|
|
"success"
|
|
],
|
|
[
|
|
"before",
|
|
"t.typed",
|
|
{
|
|
"id": 2
|
|
}
|
|
],
|
|
[
|
|
"run",
|
|
"t.typed",
|
|
2
|
|
],
|
|
[
|
|
"after",
|
|
"t.typed",
|
|
"success"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"code": "const r = []; r.push(await tools.t.echo({ deny: true }).catch((e) => e.message)); r.push(await tools.t.typed({ id: 1 })); r.push(await tools.t.typed({ id: 2 }).catch((e) => e.message)); return r",
|
|
"maxToolCalls": 2,
|
|
"outcome": {
|
|
"ok": true,
|
|
"value": [
|
|
"denied",
|
|
1,
|
|
"Execution exceeded its tool-call limit of 2."
|
|
]
|
|
},
|
|
"toolCalls": [
|
|
"t.echo",
|
|
"t.typed"
|
|
],
|
|
"log": [
|
|
[
|
|
"before",
|
|
"t.echo",
|
|
{
|
|
"deny": true
|
|
}
|
|
],
|
|
[
|
|
"before",
|
|
"t.typed",
|
|
{
|
|
"id": 1
|
|
}
|
|
],
|
|
[
|
|
"run",
|
|
"t.typed",
|
|
1
|
|
],
|
|
[
|
|
"after",
|
|
"t.typed",
|
|
"success"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"code": "const ps = [tools.t.typed({ id: 'x' }), tools.t.typed({ id: 1 }), tools.t.typed({ id: 2 })]; return await Promise.allSettled(ps).then((r) => r.map((x) => x.status))",
|
|
"maxToolCalls": 1,
|
|
"outcome": {
|
|
"ok": true,
|
|
"value": [
|
|
"rejected",
|
|
"fulfilled",
|
|
"rejected"
|
|
]
|
|
},
|
|
"toolCalls": [
|
|
"t.typed"
|
|
],
|
|
"log": [
|
|
[
|
|
"before",
|
|
"t.typed",
|
|
{
|
|
"id": 1
|
|
}
|
|
],
|
|
[
|
|
"run",
|
|
"t.typed",
|
|
1
|
|
],
|
|
[
|
|
"after",
|
|
"t.typed",
|
|
"success"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"code": "tools.t.typed({ id: 'x' }); return 1",
|
|
"outcome": {
|
|
"ok": true,
|
|
"value": 1
|
|
},
|
|
"toolCalls": [],
|
|
"log": []
|
|
},
|
|
{
|
|
"code": "await tools.t.typed({ id: 'x' }); return 1",
|
|
"outcome": {
|
|
"ok": false,
|
|
"kind": "InvalidToolInput",
|
|
"message": "Invalid input for tool 't.typed': SchemaError(Expected number\n at [\"id\"])"
|
|
},
|
|
"toolCalls": [],
|
|
"log": []
|
|
}
|
|
]
|
|
}
|