Repository navigation
feat: plan strategies — decomposition, beam sequences, hierarchical routing, richer state - #9
Merged
BillionsBobby merged 1 commit intoSep 18, 2026
Conversation
…al routing, richer state Four measured plan strategies on top of the multi-step plan contract: - decompose: split the request into ordered sub-goals (built-in rule splitter or an injected function, e.g. an LLM with the tool catalog), then route each sub-goal as a single-step decision — the question shape Jev answers most confidently. thread_context threads the original request, the Sub-goal k of N marker, and routing progress into each step's state. - sequence=beam with diversity_penalty (batch): beam-search the joint sequence over Jev's per-step probability distributions with a repetition penalty instead of independent argmax. jev_choice keeps the argmax; overrides are recorded in fallback. The same penalty enables per-step diversity re-ranking in serial/decompose modes. - group_by: hierarchical routing (coarse Choice over candidate groups, then within the winning group), both calls kept in raw_jev_stages. - state_detail=targets (serial) and plan_hint: richer state options. Measured (10 Toolathlon tasks, first-5 tool-call prediction, real MCP tool inventories, Jev typesafe/jev-1.13-20260917): position-wise hits 38% -> 44% with tool-aware LLM decomposition + thread_context, set overlap 54% -> 58%; batch+beam (lambda=2.0) 28% -> 36% at zero extra provider calls. MCP-Atlas regression check with the same configuration: 29% -> 44% hits. Standalone group_by / state_detail=targets did not improve the baseline and are documented as negative results. 27/27 tests pass, tsc clean, live-verified against the OpenRouter Jev endpoint.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Follow-up to #1. Our Toolathlon experiment (issue #2) showed that plain serial plans fix stateless repetition only partially: Jev still answers "which capability handles the whole request" (favoring deliverable tools like
write_file), degrades on large candidate sets, and locks onto one tool across steps. This PR adds four measured plan strategies that address those failure modes, and reports both the wins and the honest negative results.Strategies added (
PlanStrategy, CLI flags in parentheses)decompose: "rule" | DecomposeFn(--decompose rule): split the request into ordered sub-goals — a built-in discourse-marker splitter, or an injected function (e.g. an LLM given the tool catalog) — then route each sub-goal as a single-step decision. Decomposition turns a multi-step request into the single-action question shape Jev answers most confidently (confidence ≈ 1.0 in the README demo regime).thread_context: true: in decompose mode, each step's state includes the original request, aSub-goal k of Nmarker, and the capabilities routed so far.sequence: "beam"+diversity_penalty: λ(--sequence beam --diversity-penalty 2.0): batch mode beam-searches the joint sequence over Jev's per-step probability distributions with a repetition penalty, instead of independent argmax. Zero extra provider calls.jev_choicekeeps the argmax; overrides are recorded infallback.reason(Jev owns probabilities, the router owns the sequence policy). The same penalty also enables per-step diversity re-ranking in serial/decompose modes.group_by: "server" | "type"(--group-by server): hierarchical routing — coarse Choice over candidate groups (metadata.group/metadata.server, falling back to capability type), then a Choice within the winning group. Both calls preserved inraw_jev_stages.state_detail: "targets"andplan_hint: string[](SDK): richer serial state options (extracted files/URLs/identifiers; a caller-supplied plan sketch).Also fixes a regression from #1: serial steps now actually ask the per-step question (
...at step N...) instead of the generic route question.Measured results (all real live calls, Jev
typesafe/jev-1.13-20260917)Toolathlon, 10 tasks, first-5 tool-call prediction vs labeled gold, real tool inventories from 9 live MCP servers (16–68 candidates/task):
thread_context)Batch mode:
sequence: "beam"(λ=2.0) lifts hits 28% → 36% and overlap 32% → 48% at zero extra provider cost.MCP-Atlas regression check (10 tasks, same best config): hits 29% → 44%, overlap 44% → 69% (DeepSeek reference: 49% / 73%).
Negative results, documented: standalone
group_by(26%),state_detail: "targets"(30%), serial diversity re-rank, andplan_hintdid not beat the serial baseline on Toolathlon; they remain available as options.Engineering
src/planning.ts(beamSelectSequence,ruleDecompose,extractTargets, grouping); strategy orchestration inrouter.tsreusing the sharedfinalize/decideWithStagespath —route()behavior unchanged.plan()accepts all strategy options; CLI exposes them as flags; plans still append-only in.jevrouter/plans/.tsc --noEmitclean.