Skip to content

[Bug] decideFilesense gates navigation on keyword regexes, so paraphrasing the same question disables it #425

Description

@ceilf6

What

trigger-policy.ts decides whether a query task needs directory navigation by regex-matching the task text:

function taskMentionsStructureNeed(task: AgentTask): boolean {
  const text = task.description.toLowerCase();
  return /architecture|structure|overview|map||||||/.test(text);
}

Ask the same question in different words and navigation does not fire.

Observed

Two phrasings of the same question, same fixture, same arm:

task text navigated result
说明 src 下四个顶层目录各自的职责,以及一个 feature 目录内部的分层约定 yes (271 entries) FAIL
这个代码库按什么原则分层?说明各层之间允许的依赖方向,以及一个业务域内部是怎么组织的 no FAIL

The second run: 7 LLM calls, 263s, one executed step, filesense: [], and an answer of "I have no evidence about this codebase's layering". A question about layering and dependency direction plainly needs to look at the directory tree; none of 架构 / 结构 / 目录 / 模块 / 梳理 / 理解 appears in it, so the gate never opened.

Why it matters

The gate is meant to keep navigation off tasks that do not need it — a reasonable goal, since scanning costs tokens. But keyword matching makes the decision depend on vocabulary rather than need. A user who says "分层" instead of "结构", or "how is this organised" instead of "structure", silently gets a worse agent.

It also distorts measurement: an ablation comparing arms cannot attribute a difference to navigation quality when navigation fires for one phrasing and not another. I hit this while rewriting the ablation task set to remove location hints from the prompts (#422 follow-up) — removing the hints also removed the trigger words, which is not a distinction the user would expect to be making.

Suggested direction

The task type and the plan already carry the signal that the regex is trying to recover. A query whose plan contains search_code / list_directory steps is, by construction, a query that needs to locate something. Deciding from the plan shape rather than from the prompt's vocabulary would be both more robust and cheaper to reason about.

If a text signal is kept, it should at least be a fallback rather than the gate, and the current 10-alternative Chinese/English list is not a maintainable way to express "this question is about where things live".

Related

Found while running the filesense ablation. Same family as #419 (query never planned at all) and #420 (bare focus-dir names as scan roots): the capability is fine, the conditions under which it is invoked are not.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions