Repository navigation
Description
Overview
When the skill pipeline finds no match above the confidence threshold (0.8), the agent silently falls through to the general 13-tool path. This overwhelms the model with tools it doesn't need and produces poor or empty responses. Instead, the agent should detect the ambiguous-intent case and ask the user for clarification.
Problem Statement
Current behavior:
- User sends a short or ambiguous message (e.g., "create")
- Skill pipeline scores it at 0.754 — below the 0.8 threshold
- Agent loop falls through to the full tool set (13 tools)
- Model receives 13 tools + full conversation history and returns an empty or incorrect response
- User sees a blank UI or a generic fallback message
Expected behavior:
- User sends ambiguous message
- Skill pipeline finds no confident match
- Agent detects the low-confidence/no-match case
- Agent responds with a clarifying question: "Could you tell me more about what you'd like to do?"
- User clarifies, next turn has enough context for a confident skill match
Proposed Solution
In packages/agent/src/local_agent/agent_loop.rs, before dispatching to the inference engine, check whether a skill was matched. If skill_match is None (or confidence < threshold) and the user message is short or lacks clear intent, return a clarifying question directly — without calling the model at all.
Detection heuristics (start simple):
- No skill match AND user message is under ~10 words
- Or: top skill confidence is between 0.5–0.8 (some signal but not enough)
Clarification response:
Return a short, helpful question as the agent response. No tool calls needed.
Acceptance Criteria
- When skill confidence is below threshold and message is ambiguous, agent responds with a clarifying question instead of proceeding with all tools
- Clarifying question is returned as a normal agent response (visible in UI)
- When skill confidence is below threshold but message is clearly actionable (long, contains specific nouns), agent still proceeds with full tool set
- Empty-response fallback in
agent_loop.rs(lines ~269–274) is unified with or superseded by this clarification path - Unit test covering the low-confidence clarification path
- Code passes
bun run quality:fix - Tests pass (
bun run test:all)
Technical Specifications
Reference Files
- Agent loop:
packages/agent/src/local_agent/agent_loop.rs— skill dispatch and inference entry point; clarification logic goes before the inference call - Skill pipeline:
packages/agent/src/skill_pipeline.rs—SkillMatchstruct holdsconfidenceand matched skill;Nonemeans no match above threshold - Empty fallback (to unify):
packages/agent/src/local_agent/agent_loop.rslines ~269–274 — current hardcoded fallback for empty model output
Implementation Details
The agent loop already receives the SkillMatch result before calling inference. The check should be inserted at the point where skill_match is inspected:
// Pseudocode — in agent_loop run_turn or similar
if skill_match.is_none() && is_ambiguous(&user_message) {
let clarification = "I'm not sure what you'd like to do. Could you give me a bit more detail?";
return Ok(AgentTurnResult {
response: clarification.to_string(),
tool_calls_made: vec![],
usage: Default::default(),
});
}is_ambiguous can start as: word_count < 10 && !contains_proper_noun_or_url.
Non-Goals
- This does not change the skill confidence threshold (0.8)
- This does not affect turns where a skill IS matched
- This does not add multi-turn clarification state tracking (single clarifying question only, for now)
Related Issues
- Unify agent guidance rules into a single source for local agent and gRPC tool layer #1089 (unify MCP initialize instructions with local agent seed prompts)
Activity
malibio commentedon May 17, 2026
Frontend baseline: 3918 passed, 0 failed (128 test files)
Add clarification for low-confidence skill matches (closes #1090) (#1128