Skip to content

fix(agent): widen planner gate and wire LLM classifier into Coordinator (#4732)#4792

Closed
ashishexee wants to merge 1 commit into
esengine:main-v2from
ashishexee:fix/4732-planner-gate-improvement
Closed

fix(agent): widen planner gate and wire LLM classifier into Coordinator (#4732)#4792
ashishexee wants to merge 1 commit into
esengine:main-v2from
ashishexee:fix/4732-planner-gate-improvement

Conversation

@ashishexee

Copy link
Copy Markdown
Contributor

Closes #4732

Problem

Configuring a planner_model forces every conversation through the planner, even for simple questions like "who wrote this file?" or "is this safe?". The TaskWarrantsPlanner heuristic only bypassed the planner for inputs starting with what/why/how/show/run + 5 Chinese prefixes — everything else (including who, where, when, explain, describe, is, are, can, does, etc.) was sent to the planner unnecessarily, doubling latency.

Additionally, the existing LLM AutoPlanClassifier (which makes a tiny 80-token classification call) was only wired into the single-model shouldAutoPlan path — the two-model Coordinator never used it.

Changes

1. Widened isLowRiskQuestion (internal/control/auto_plan.go)

Added 20+ missing English prefixes: who, where, when, which, whose, whom, explain, describe, tell, list, summarize, summarise, compare, difference, is, are, can, could, do, does, did, should, would, will, what's (apostrophe variant handled via normalization).

Added 8 missing Chinese prefixes: 介绍一下, 说一下, 帮我看, 帮我查, 是什么, 有没有, 能不能, 可以吗, 对吗, 是不是, 请问.

Complex intent terms (implement, refactor, migrate, etc.) still override these prefixes — "how do I implement X" still goes through the planner.

2. Exported AutoPlanClassifier + added NewPlannerGate (internal/control/auto_plan.go)

Exported the autoPlanClassifier interface as AutoPlanClassifier. Added NewPlannerGate(classifier) that wraps TaskWarrantsPlanner with LLM classifier support for borderline cases (score ≤ 2), mirroring the single-model shouldAutoPlan path. When classifier is nil, falls back to pure heuristic.

3. Wired classifier into Coordinator (internal/boot/boot.go)

Moved classifier creation BEFORE the Coordinator creation. Changed control.TaskWarrantsPlannercontrol.NewPlannerGate(classifier) so the two-model path gets the same LLM classification the single-model path already had.

4. Updated controller types (internal/control/controller.go)

Changed Classifier field from unexported autoPlanClassifier to exported AutoPlanClassifier.

Tests

  • 35 test cases for TaskWarrantsPlanner (was 12) — covers all new English + Chinese prefixes + complex intent overrides
  • 3 new tests for NewPlannerGate: nil classifier fallback, classifier override (both true/false), low-risk skip

Files Changed

File Change
internal/control/auto_plan.go Widened isLowRiskQuestion, exported AutoPlanClassifier, added NewPlannerGate
internal/control/auto_plan_test.go 35 test cases + 3 new NewPlannerGate tests
internal/control/controller.go Updated Classifier field to exported type
internal/boot/boot.go Moved classifier creation before Coordinator, use NewPlannerGate

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) labels Jun 18, 2026
@SivanCola

Copy link
Copy Markdown
Collaborator

Thanks @ashishexee. I consolidated the PE planner-gate portion of this PR into #4938.

What was kept:

  • the low-risk question prefix set is wider;
  • the optional auto-plan classifier is now wired into the two-model Coordinator gate as well as the single-model auto-plan path.

Your contribution is credited in #4938 under Repository Contributor Credits. Closing this PR in favor of the integration PR.

@SivanCola SivanCola closed this Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

2 participants