agent: fix stall state always firing on normal text responses

The "no tools" stall condition (totalToolCalls==0 && hadContent) fired
whenever the bot replied in plain text without calling any tools, which
is the normal completion path. The UI would then see agentStalled before
the done message and never transition back to agentIdle.

Removed the "no tools" stall; only the max-steps limit case is a real
stall worth surfacing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Levi Neely 2026-04-07 10:51:10 +02:00
parent b45f81908e
commit 939f41013e
1 changed files with 1 additions and 7 deletions

View File

@ -45,7 +45,6 @@ func Run(ctx context.Context, cfg Config, state State) error {
}
var totalToolCalls int
var hadContent bool
hitLimit := false
for step := range maxSteps {
@ -97,9 +96,6 @@ func Run(ctx context.Context, cfg Config, state State) error {
if !done {
return fmt.Errorf("step %d: stream ended without done event", step)
}
if content.Len() > 0 {
hadContent = true
}
totalToolCalls += len(toolCalls)
// Announce and execute tool calls.
@ -163,11 +159,9 @@ func Run(ctx context.Context, cfg Config, state State) error {
}
}
// Surface stall conditions so the UI can indicate them.
// Surface stall: only when the step limit was hit without completing.
if hitLimit {
emit(cfg, OutputMsg{Role: "stalled", Content: "max steps"})
} else if totalToolCalls == 0 && hadContent {
emit(cfg, OutputMsg{Role: "stalled", Content: "no tools"})
}
return nil