Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,12 @@ grep -c 'bypass:' /tmp/opencode-jev.log # requests handed to the LLM untouched
| `bypass: jev choice X listed but missing from payload — ...` | Name passed the criteria list but matched no payload entry (format mismatch edge case). | Full tool list. |
| `bypass: jev unavailable (see preceding 'jev ...' error line) — ...` | The round-trip failed; the **preceding** error line names why. | Full tool list. |

Error/context lines that precede a `bypass: jev unavailable`:
Error/context lines that precede a `bypass: jev unavailable`, plus the
`note:` line (which can precede **any** tagged line, `apply:` included):

| Line | Meaning |
| --- | --- |
| `note: N tools exceed criteria cap 254 — first 254 offered to jev` | Payload has more than 254 function tools; the excess is invisible to Jev's choice (a pick among the kept tools still trims correctly). Operator awareness only — behavior unchanged. |
| `jev http 500` (or any non-401/403 status) | Transient provider failure — plugin keeps trying next request. |
| `jev http 401 (invalid key, routing disabled)` | **Latched off.** Auth failed; all later requests bypass silently with zero jev round-trips and **no further log lines**. Fix the key and restart OpenCode. |
| `jev answer malformed` | Jev's JSON didn't parse into `{choice, confidence}`. |
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ async function askJev(
state: string,
names: string[],
): Promise<JevAnswer | undefined> {
if (names.length > MAX_CRITERIA - 1)
log(
`note: ${names.length} tools exceed criteria cap ${MAX_CRITERIA - 1} — first ${MAX_CRITERIA - 1} offered to jev`,
);
const criteria: Record<string, string> = {
respond_to_user: "Task is complete, or clarification from user is required",
};
Expand Down
23 changes: 23 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,3 +564,26 @@ test("22. bogus config timeoutMs (0 / non-numeric): default used, routes normall
assert.equal(calls.length, 1);
}
});

test("23. 260 tools: criteria truncated to first 254 + note logged, trim still applies", async () => {
const { calls, holder } = await setupPlugin(undefined, () =>
jevResponse(choice("tool_0", 0.99)),
);
assert.ok(holder.captured);
const payload = anthropicPayload();
payload.tools = Array.from({ length: 260 }, (_, i) => ({
name: `tool_${i}`,
input_schema: {},
}));
const event = jsonEvent(ANTHROPIC_URL, payload);
await holder.captured!(event);
const jevBody = JSON.parse(calls[0].init.body);
const criteria = jevBody.questions.next_tool.criteria;
// 254 kept tools + the reserved respond_to_user slot; tool_254..259 invisible.
assert.equal(Object.keys(criteria).length, 255); // MAX_CRITERIA: 254 tools + respond_to_user
assert.ok("tool_253" in criteria);
assert.ok(!("tool_254" in criteria));
const logText = readFileSync(process.env.JEV_DEBUG_FILE!, "utf8");
assert.match(logText, /\[jev\] note: 260 tools exceed criteria cap 254/);
assert.match(logText, /\[jev\] apply: tools trimmed to tool_0/);
});
Loading