Skip to content

fix: stop delegated model runs after a task outcome is decided - #81

Merged
jerelvelarde merged 2 commits into
CopilotKit:mainfrom
wangtaotaotao95:fix/stop-model-after-task-outcome
Oct 6, 2026
Merged

jerelvelarde merged 2 commits into
CopilotKit:mainfrom
wangtaotaotao95:fix/stop-model-after-task-outcome

Conversation

@wangtaotaotao95

@wangtaotaotao95 wangtaotaotao95 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Calling finish_task, ask_user, or a prepare tool sets a task outcome, but the model loop still requests another turn. If that request fails after its retries, a completed task or a task awaiting input/review becomes failed instead. A completed task can even have a “Work completed” event alongside its failure status.

Stop the delegated model loop between turns once an outcome is set. The current turn's tools still settle normally. A replayed, already-successful reviewed action does not set an outcome, so the model can continue using its saved receipt. Cancellation, lease checks and provider errors before an outcome retain their existing handling.

Verification on Node 24.21.0 / pnpm 11.19.0:

  • Four new regressions fail on main and pass here: finish, ask for input, prepare email and prepare event. A local Responses-protocol fixture returns 503 on any unnecessary follow-up; each case now makes exactly one request and saves the expected status.
  • Full suite: 210/210 pass, including completed-action replay, provider retry and worker interruption coverage.
  • Lint, root/mobile typecheck, worker typecheck, server build, and web/iOS/Android exports pass.

Tests use local fixtures only; no live model API or Google writes were exercised. Platform exports do not verify native device behavior.

Follow-up verification — 2026-10-06

Resolved the production conflict against main 73a7149, keeping current workspace reads, provider-specific computer/search instructions, cancellation and browser guards, plus the outcome stop predicate. Full suite: 392 tests passed. Root/mobile/worker typechecks, lint and server build pass on Node 26.8.2. Browser and container checks are delegated to the new CI run.

@jerelvelarde jerelvelarde left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stop-after-outcome fix is valuable: all 8 focused model outcome/worker tests pass, including one provider request and persisted review/input/completion states. The description covers verification and integration limits; no new security blocker found. Please resolve the production conflict in apps/server/src/engine/model.ts against current main, retaining its current workspace reads, provider-specific computer instructions and cancellation/browser guards while adding shouldContinue. Rerun CI on the integrated head; the old-head browser jobs currently fail.

@jerelvelarde jerelvelarde left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed author integration: model.ts conflicts are resolved and current main merges cleanly. Nine model outcome/worker tests passed; finish/input/review outcomes stop follow-up turns while action replay, workspace/provider instructions, cancellation and browser guards remain intact. Clear value and described limits, no actionable security/correctness blocker. Merge remains gated on current exact-head required CI.

@jerelvelarde
jerelvelarde merged commit 6abdb93 into CopilotKit:main Oct 6, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants