Skip to content

feat: skip the Jev round-trip when trimming can only reproduce the tools array - #22

Merged
danipl merged 1 commit into
mainfrom
9-feat-skip-jev-roundtrip-lone-candidate
Oct 5, 2026
Merged

danipl merged 1 commit into
mainfrom
9-feat-skip-jev-roundtrip-lone-candidate

Conversation

@danipl

@danipl danipl commented Oct 5, 2026

Copy link
Copy Markdown
Owner

What

Closes #9. routePayload now returns the silent passthrough before askJev when there is no candidate function tool, or when the lone candidate is the only entry in payload.tools — every Jev outcome (trim / bypass) hands the big model the identical request, so the round-trip is pure added latency (up to timeoutMs, default 2 s).

Correction to the issue's proposed fix

Issue #9 proposed guarding on names.length < 2. Verified against the trim implementation (src/index.ts): the filter keeps only entries matching the chosen name, so a Responses-API payload like [{type:web_search}, {type:function, function:{name:shell}}] has exactly one candidate but a successful trim drops the built-in — a real, tested behavior (test 7). The literal guard would have regressed it. Shipped guard instead fires only when the trim is provably a no-op:

if (names.length === 0 || (names.length === 1 && (payload.tools as unknown[]).length === 1)) {
  return false;
}```

## Acceptance criteria

- [x] Black-box test 20: single function tool → byte-identical passthrough and `calls.length === 0` (no fetch pattern)
- [x] DEVELOPMENT.md §5 silent-paths list updated
- [x] `typecheck` / `test` (22/22) / `build` green
- [x] Invariants: no throw, rebuilt passthrough, `tool_choice` untouched, latch untouched

## Skipped (known ceilings)

- Duplicate-name payloads (`tools: [read, read]`) still take the round-trip; trim there is also a no-op but OpenCode never emits duplicate tool names — tighten only if real.

@danipl
danipl merged commit 90994a9 into main Oct 5, 2026
2 checks passed
@danipl
danipl deleted the 9-feat-skip-jev-roundtrip-lone-candidate branch October 5, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skip the Jev round-trip when fewer than two candidate tools exist

1 participant