Skip to content

Commit e534f72

Browse files
committed
fix: flaky TestAdaptAddsTool — use exact word match for intent detection to avoid map iteration nondeterminism
1 parent bb7ce53 commit e534f72

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

engine/tool_selector.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,18 @@ func (ts *ToolSelector) Adapt(feedback string) {
316316
}
317317

318318
// Determine which intents this feedback relates to by checking existing task patterns.
319-
// Look for "for <intent>" or "during <intent>" in the feedback.
319+
// Look for exact word match on intent names to avoid ambiguity
320+
// (e.g., "debug task" should match "debug" not "search" even though it contains "search" substring).
320321
var relatedIntent string
322+
words := strings.Fields(lower)
321323
for intent := range ts.TaskPatterns {
322-
if strings.Contains(lower, intent) {
323-
relatedIntent = intent
324+
for _, w := range words {
325+
if w == intent {
326+
relatedIntent = intent
327+
break
328+
}
329+
}
330+
if relatedIntent != "" {
324331
break
325332
}
326333
}

0 commit comments

Comments
 (0)