Skip to content

fix(desktop,runtime): interrupt and bound empty assistant loops - #4138

Open
Rangsh wants to merge 1 commit into
apache:mainfrom
Rangsh:fix/empty-ai-reply-loop-interrupt
Open

fix(desktop,runtime): interrupt and bound empty assistant loops#4138
Rangsh wants to merge 1 commit into
apache:mainfrom
Rangsh:fix/empty-ai-reply-loop-interrupt

Conversation

@Rangsh

Copy link
Copy Markdown

Interrupt the active desktop turn before sending a plain Enter follow-up, and clean up transient messages retracted by the stop operation.

Bound repeated textless tool steps when no explicit maxSteps is configured, while preserving normal multi-step workflows and explicit step limits.

Fixes#4083

Summary

Desktop mid-turn plain Enter used to queue a follow-up, so a runaway empty-reply loop never stopped and the typed message could not take effect. Plain Enter now interrupts the active turn first, then starts a new root send; Shift+Enter still steers. In the runtime agent loop, when maxSteps is unset, consecutive identical textless tool-only steps are capped so the turn ends instead of flooding blank assistant replies, without changing normal multi-step work or explicit step budgets.

Fixes#4083

Verification

  • node --test --test-name-pattern="stops an unbounded loop after consecutive identical empty" packages/runtime/dist/__tests__/ai-sdk-backend.test.js — pass
  • Desktop follow-up submit routing tests — pass
  • Rebased onto current apache/makamain and resolved conflict with fix(runtime): preserve Plan final responses #3886 in ai-sdk-backend.test.ts
  • Did not run full-repo lint / format:check / typecheck / full workspace npm test

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope:

Cursor (Composer) helped locate the empty-loop / mid-turn send paths, implement the runtime empty-step bound and Desktop interrupt-on-send behavior, add/adjust tests, and rebase through the upstream conflict. Human owns the final review and submission.

Affected commits should retain: Generated-by: Cursor

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Interrupt the active desktop turn before sending a plain Enter follow-up,
and clean up transient messages retracted by the stop operation.
Bound repeated textless tool steps when no explicit maxSteps is configured,
while preserving normal multi-step workflows and explicit step limits.
Fixesapache#4083
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/MUnder 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: maka loop leads to repeated empty AI replies and cannot be interrupted by message

1 participant

@Rangsh