Skip to content

Ask for clarification when skill confidence is below threshold instead of falling through to full tool set #1090

Closed

Description

@malibio

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:

  1. User sends a short or ambiguous message (e.g., "create")
  2. Skill pipeline scores it at 0.754 — below the 0.8 threshold
  3. Agent loop falls through to the full tool set (13 tools)
  4. Model receives 13 tools + full conversation history and returns an empty or incorrect response
  5. User sees a blank UI or a generic fallback message

Expected behavior:

  1. User sends ambiguous message
  2. Skill pipeline finds no confident match
  3. Agent detects the low-confidence/no-match case
  4. Agent responds with a clarifying question: "Could you tell me more about what you'd like to do?"
  5. 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 — SkillMatch struct holds confidence and matched skill; None means no match above threshold
  • Empty fallback (to unify): packages/agent/src/local_agent/agent_loop.rs lines ~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

Activity

  1. malibio commented on May 17, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 3918 passed, 0 failed (128 test files)

  2. self-assigned this
    on May 17, 2026
  3. added a commit that references this issue on Jun 22, 2026
    ddb2c14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions