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
2 changes: 1 addition & 1 deletion docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ rebuild threw; the consumed original is passed through as the last resort).

Silent paths (no log line by design, request simply untouched):
non-POST / non-target URLs, non-primary `event.kind` (title, compaction),
payloads with no usable tools, and everything after the 401 latch. If the
payloads with no usable tools, payloads whose single function tool is the only entry in `tools`, and everything after the 401 latch. If the
log goes quiet mid-session, check for a latch line first.

### Verify trimming actually happened
Expand Down
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,13 @@ async function routePayload(
payload: Record<string, unknown>,
): Promise<boolean> {
const names = toolNames(payload.tools as unknown[]);
if (names.length === 0) return false;
// No usable candidate, or a lone candidate with nothing else in the payload:
// trimming can only reproduce the original tools array, so there is no
// decision for Jev and the round-trip would be pure added latency.
// (A built-in alongside the lone tool still counts — trimming drops it.)
if (names.length === 0 || (names.length === 1 && (payload.tools as unknown[]).length === 1)) {
return false;
}
// Invalid key latched earlier: skip the round-trip, zero added latency.
if (jevAuthFailed) return false;
// A thrown round-trip (fetch network error, timeout abort, non-JSON body)
Expand Down
13 changes: 13 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,3 +503,16 @@ test("19. body read fails (stream errors mid-read): original returned, no jev ca
const logText = readFileSync(process.env.JEV_DEBUG_FILE!, "utf8");
assert.match(logText, /\[jev\] bypass: body read failed/);
});

test("20. single function tool: passthrough, no fetch", async () => {
const { calls, holder } = await setupPlugin();
assert.ok(holder.captured);
const payload = {
...anthropicPayload(),
tools: [{ name: "read", input_schema: {} }],
};
const event = jsonEvent(ANTHROPIC_URL, payload);
await holder.captured!(event);
assert.deepEqual(await bodyJson(event), payload);
assert.equal(calls.length, 0); // nothing for jev to decide, no round-trip
});
Loading