Skip to content

fix: preserve prompt ownership during repetition recovery - #814

Merged
agenteinstinct1-max merged 5 commits into
dev-vibecodedfrom
arena/fd199c89-silvercode
Nov 11, 2026
Merged

agenteinstinct1-max merged 5 commits into
dev-vibecodedfrom
arena/fd199c89-silvercode

Conversation

@agenteinstinct1-max

@agenteinstinct1-max agenteinstinct1-max commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Issue for this PR

Closes #738

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Bounds repetition recovery and keeps queued, interrupted, and unfinished turns associated with the correct prompt. Repeated-result supersession now requires an assistant generation belonging to that prompt with finish: "tool-calls"; a newer settled answer alone is not sufficient.

Retains the text-only repetition guard and raw reasoning behavior. Also preserves legacy shell/Bash compatibility and includes the supporting session schema, compaction, and test changes.

Update 2 (head 54026cd, on top of bedf48d): adds fix(session): resume declined waits with terminal child results. A failed wait-for-subagent finish is no longer counted as real tool work when it is the whole declined-wait checkpoint; the refusal is identified by its exact FinishTool message, not a substring. This is a small product change in packages/opencode/src/session/prompt.ts, plus test coverage. The Windows db-path smoke repair in the same commit is test-only: it makes the db path predicate portable (drive-letter and UNC paths, with pure controls) and changes no product code. The broader true-caller fix for the retry/wait failure remains OFF (not part of this PR) and its underlying behavior is still RED.

Related: #780.

How did you verify your code works?

Local runs on the previous head (bedf48d, tree 920b8118):

  • Full prompt suite: 194 passed, 0 failed, 1 skip, 1482 assertions.
  • Compaction suite: 69 passed, 0 failed, 1 skip, 248 assertions.
  • CLI tests: 13 passed, 67 assertions.
  • Focused recovery tests: 32 passed, 491 assertions.
  • Full TypeScript typecheck was not run locally (2 GB host, not capable). Type status comes from the normal CI run on this head.

Fresh CI on bedf48d then reported one failure per OS, neither reproduced locally before repair:

Repair verification on the exact new head 54026cd (writer-run, Linux host):

  • Focused recovery tests: 10 passed, 53 assertions.
  • Full prompt suite: 202 passed, 0 failed, 1 skip, 1509 assertions.
  • Compaction suite: 69 passed, 0 failed, 1 skip, 248 assertions.
  • Retry fixture: 12 passed, 65 assertions.
  • db path (portable predicate incl. pure controls): 21 passed.

An independent source review of the earlier tree (bedf48d) reported no must-fix or should-fix items introduced by this change; it did not read every line of the large prompt test file, and it does NOT cover the new 54026cd delta. No current remote CI result is claimed for the new head: fresh full CI, typecheck, and an exact named review of the new delta are still required before merge.

Screenshots / recordings

N/A.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Update 3 (head 82567b4, on top of 54026cd)

Test-only type repair in packages/opencode/test/session/prompt.test.ts (10 insertions, 7 deletions): an assistant-role typeguard now narrows result.info before the parentID assertions, which keeps the original parent/content assertions intact. Product code and the smoke test are unchanged. Focused suite on the exact head (writer-run, Linux): 10 passed, 0 failed, 60 assertions, 14.86s. No local typecheck was run - authoritative fresh CI typecheck on this head is required. Earlier full-suite evidence predates this guard; current proof scope is the focused suite plus fresh CI.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Hey! Your PR title Fix session recovery and queued prompt ownership doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@kilo-code-bot

kilo-code-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • packages/opencode/test/session/prompt.test.ts - No issues
Previous Review Summaries (3 snapshots, latest commit 54026cd)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 54026cd)

Status: No Issues Found | Recommendation: Merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 0
Issue Details (click to expand)

No unresolved issues remain in the changed code. The previously reported continuationMarker omission of COMPACTION_CONTINUATION in packages/opencode/src/session/subagent-result.ts is no longer present in the current PR state.

Files Reviewed (12 files)
  • packages/opencode/src/session/compaction.ts
  • packages/opencode/src/session/llm/repetition-guard.ts
  • packages/opencode/src/session/message-v2.ts
  • packages/opencode/src/session/prompt.ts
  • packages/opencode/src/session/subagent-result.ts
  • packages/opencode/test/cli/run/fixture-session-isolation.test.ts
  • packages/opencode/test/cli/smokes/read-only.test.ts
  • packages/opencode/test/lib/cli-process.ts
  • packages/opencode/test/lib/llm-server.ts
  • packages/opencode/test/session/compaction.test.ts
  • packages/opencode/test/session/prompt.test.ts
  • packages/schema/src/v1/session.ts

Notes: Reviewed current PR metadata/head and incremental diff context available in this environment. Some auxiliary read-only shell inspection commands were unavailable/rejected, so this summary is based on the PR diff/state and file contents examined here. No inline comments posted.

Previous review (commit ea52aa8)

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/opencode/src/session/subagent-result.ts 72 continuationMarker omits COMPACTION_CONTINUATION while continuationPromptID and isNudge include it
Files Reviewed (2 files)
  • packages/opencode/src/session/subagent-result.ts - 1 issues
  • packages/opencode/test/session/prompt.test.ts - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit 32510f5)

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/opencode/src/session/subagent-result.ts 72 continuationMarker omits COMPACTION_CONTINUATION while continuationPromptID and isNudge include it
Files Reviewed (9 files)
  • packages/opencode/src/session/compaction.ts - 0 issues
  • packages/opencode/src/session/llm/repetition-guard.ts - 0 issues
  • packages/opencode/src/session/message-v2.ts - 0 issues
  • packages/opencode/src/session/prompt.ts - 0 issues
  • packages/opencode/src/session/subagent-result.ts - 1 issues
  • packages/opencode/test/lib/llm-server.ts - 0 issues
  • packages/opencode/test/session/compaction.test.ts - 0 issues
  • packages/opencode/test/session/prompt.test.ts - 0 issues
  • packages/schema/src/v1/session.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by free · Input: 166.4K · Output: 3.3K · Cached: 150.5K

@agenteinstinct1-max agenteinstinct1-max changed the title Fix session recovery and queued prompt ownership fix: preserve prompt ownership during repetition recovery Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@agenteinstinct1-max
agenteinstinct1-max merged commit ecd9a99 into dev-vibecoded Nov 11, 2026
8 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.

opencode: recover the task after the repetition guard trips instead of abandoning the turn

1 participant