fix(agent): widen planner gate and wire LLM classifier into Coordinator (#4732)#4792
Closed
ashishexee wants to merge 1 commit into
Closed
fix(agent): widen planner gate and wire LLM classifier into Coordinator (#4732)#4792ashishexee wants to merge 1 commit into
ashishexee wants to merge 1 commit into
Conversation
This was referenced Jun 20, 2026
Collaborator
|
Thanks @ashishexee. I consolidated the PE planner-gate portion of this PR into #4938. What was kept:
Your contribution is credited in #4938 under Repository Contributor Credits. Closing this PR in favor of the integration PR. |
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.
Closes #4732
Problem
Configuring a
planner_modelforces every conversation through the planner, even for simple questions like "who wrote this file?" or "is this safe?". TheTaskWarrantsPlannerheuristic only bypassed the planner for inputs starting withwhat/why/how/show/run+ 5 Chinese prefixes — everything else (includingwho,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-modelshouldAutoPlanpath — 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+ addedNewPlannerGate(internal/control/auto_plan.go)Exported the
autoPlanClassifierinterface asAutoPlanClassifier. AddedNewPlannerGate(classifier)that wrapsTaskWarrantsPlannerwith LLM classifier support for borderline cases (score ≤ 2), mirroring the single-modelshouldAutoPlanpath. 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.TaskWarrantsPlanner→control.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
Classifierfield from unexportedautoPlanClassifierto exportedAutoPlanClassifier.Tests
TaskWarrantsPlanner(was 12) — covers all new English + Chinese prefixes + complex intent overridesNewPlannerGate: nil classifier fallback, classifier override (both true/false), low-risk skipFiles Changed
internal/control/auto_plan.goisLowRiskQuestion, exportedAutoPlanClassifier, addedNewPlannerGateinternal/control/auto_plan_test.goNewPlannerGatetestsinternal/control/controller.goClassifierfield to exported typeinternal/boot/boot.goNewPlannerGate