Repository navigation
Fix per-task routing: local personas now upgrade to cloud for tool use (#371) - #401
Conversation
…enting cloud upgrade (#371) Local personas (candle 3B) get XML tools in system prompt, not native tool specs. The hasTools check only looked at nativeToolSpecs, so it was always false for local models. TaskAwareProviderRouter never triggered "tools require cloud" upgrade. Fix: check toolCount from ToolDefinitionsSource metadata (set for both native AND XML paths). Now local personas with tool-requiring tasks get upgraded to best available cloud provider. Also: clarified misleading pre-routing log, added XML tool count diagnostic log.
There was a problem hiding this comment.
Pull request overview
Fixes per-task routing so local personas correctly upgrade to a cloud provider when tools are present, even when tools are injected via XML in the system prompt (rather than native tools[] specs).
Changes:
- Update tool-presence detection to consider
toolDefinitions.toolCount(covers both native and XML tool injection paths). - Improve diagnostics: clarify the Phase 3.3 log and add an explicit log for XML tool count.
- Update planning doc status for issue #368.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/system/user/server/modules/PersonaResponseGenerator.ts | Fixes hasTools detection for XML tool injection and adds clearer routing/tool logs. |
| docs/planning/ALPHA-GAP-ANALYSIS.md | Marks #368 as completed (DONE) with PR reference. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const hasXmlTools = !!(toolMeta?.toolCount && (toolMeta.toolCount as number) > 0); | ||
| const hasTools = hasNativeTools || hasXmlTools; |
There was a problem hiding this comment.
hasXmlTools is derived solely from toolMeta.toolCount, which is populated for both native and XML tool paths. That makes the name misleading and can confuse future routing/logging changes. Consider deriving hasTools from toolCount and defining hasXmlTools as !hasNativeTools && toolCount > 0 (or renaming it to reflect it means “non-native tool injection”).
| const hasXmlTools = !!(toolMeta?.toolCount && (toolMeta.toolCount as number) > 0); | |
| const hasTools = hasNativeTools || hasXmlTools; | |
| const hasTools = !!(toolMeta?.toolCount && (toolMeta.toolCount as number) > 0); | |
| // XML tools here means "non-native tool injection" (tools present but no native specs) | |
| const hasXmlTools = !hasNativeTools && hasTools; |
Summary
hasToolsonly checkednativeToolSpecs— always false for local models (candle) which get XML tools in system prompt.TaskAwareProviderRouter.routeForTask()never triggered the "tools require cloud" upgradetoolCountfrom ToolDefinitionsSource metadata (set for both native AND XML paths). NowhasTools = hasNativeTools || hasXmlToolsThis was the core bug behind #371 and #366 — local 3B models can't use tools, but the routing that was supposed to upgrade them to cloud never fired.
Test plan
🔄 Task routing — Tools require cloud modelappears for local personas🤖 Generated with Claude Code