Skip to content

fix(continuation): detect non-Claude continuation intent; scope completion guard to final sentence - #1712

Closed
0xghost42 wants to merge 1 commit into
Twigpine:mainfrom
0xghost42:fix/1707-continuation-non-claude
Closed

0xghost42 wants to merge 1 commit into
Twigpine:mainfrom
0xghost42:fix/1707-continuation-non-claude

Conversation

@0xghost42

@0xghost42 0xghost42 commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1707.

Problem

analyzeContinuationIntent (src/utils/continuation.ts) is biased toward Claude-style output, so non-Claude models (OpenAI/Gemini/local) frequently stop after a turn instead of continuing. Two concrete causes:

  1. Completion marker matched anywhere. The COMPLETION_MARKERS guard tested the entire response, so a marker buried mid-text — e.g. The download is complete. Now installing the deps — suppressed an obvious later continuation intent.
  2. Continuation verb list too narrow. Common non-Claude verbs (process, download, compile, deploy, install, train, refactor, …) were absent, so the model's continuation intent went undetected.

Fix

  • Scope the completion guard to the final sentence. A genuinely completed last sentence is still suppressed; a marker earlier in the message no longer is. This can only reduce false suppression — a sound, completed message still falls through to shouldNudge: false.
  • Add the missing action verbs, gated behind explicit first-person intent framing (I will … deploy, Let me … install, Now I'll … compile) so they only fire as a continuation signal, plus present-progressive action statements (Now downloading the dataset) for the unpunctuated/truncated case. These do not override terminal punctuation, so a punctuated completion like Finished installing. stays suppressed by the marker guard.

Out of scope (deliberately)

The issue also suggests raising MAX_CONTINUATION_NUDGES (3 → 20) and inverting the default shouldNudge to true. Those are product/tuning decisions with broader blast radius, so they're left for a maintainer call rather than bundled here.

Tests

Extended src/__tests__/bugfixes.test.ts with mid-text-marker, intent-gated-verb, gerund, and still-suppressed-completion cases. Full file: 32 pass / 0 fail. tsc --noEmit clean; bun run smoke green.

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection of user intent to continue working on tasks. The system now recognizes additional natural language patterns indicating ongoing work.
    • Fixed completion marker detection to only consider the final sentence, preventing mid-text completion phrases from incorrectly blocking continuation recognition.

…etion guard to final sentence

analyzeContinuationIntent was biased toward Claude-style output (Twigpine#1707):

- The COMPLETION_MARKERS guard tested the entire response, so a marker
  buried mid-text ('The download is complete. Now installing the deps')
  suppressed an obvious later continuation intent. It now inspects only
  the final sentence — a genuinely completed last sentence is still
  suppressed, a mid-text marker no longer is.
- Added action verbs common to non-Claude models (process, download,
  compile, deploy, install, train, refactor, ...) gated behind explicit
  first-person intent framing, plus present-progressive action statements
  ('Now downloading the dataset') as a continuation signal.

Left out the issue's tuning suggestions (raising MAX_CONTINUATION_NUDGES,
inverting the default shouldNudge) as product decisions.
@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e57da3d5-672a-4603-a963-454d22e706b8

📥 Commits

Reviewing files that changed from the base of the PR and between c4aa756 and 18d6171.

📒 Files selected for processing (2)
  • src/__tests__/bugfixes.test.ts
  • src/utils/continuation.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: typecheck
  • GitHub Check: smoke-and-tests
🧰 Additional context used
📓 Path-based instructions (10)
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript with strict mode and ESM imports

Files:

  • src/__tests__/bugfixes.test.ts
  • src/utils/continuation.ts
**/*.{ts,tsx,js,jsx,py,json,md}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Follow the existing code style in the touched files

Files:

  • src/__tests__/bugfixes.test.ts
  • src/utils/continuation.ts
**/*.test.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Add or update tests when the change affects behavior

Files:

  • src/__tests__/bugfixes.test.ts
**/*.test.{ts,tsx,js}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Test the exact provider/model path you changed when possible

Files:

  • src/__tests__/bugfixes.test.ts
**/*.{ts,tsx,js,jsx,py}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Keep comments useful and concise

Files:

  • src/__tests__/bugfixes.test.ts
  • src/utils/continuation.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Follow TypeScript strict mode and type safety practices by running typecheck before submitting

Files:

  • src/__tests__/bugfixes.test.ts
  • src/utils/continuation.ts
**/*

⚙️ CodeRabbit configuration file

**/*: Apply the OpenClaude maintainer review rubric from AGENTS.md. Review the current diff, not stale discussion context. Separate real blockers from suggestions. Do not request changes for vague style churn. Treat approval as merge-ready from CodeRabbit's side, pending required human review and GitHub Checks. If checks are failing or unavailable, say so clearly instead of implying the PR is fully ready.

Files:

  • src/__tests__/bugfixes.test.ts
  • src/utils/continuation.ts
{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}

⚙️ CodeRabbit configuration file

{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}: Review tests for meaningful coverage of the changed behavior, isolation of global/env/config state, async cleanup, fake timers, provider profile leaks, and Windows-compatible assumptions. Block when risky runtime changes lack focused regression coverage or tests assert implementation details while missing the user-visible behavior.

Files:

  • src/__tests__/bugfixes.test.ts
**

⚙️ CodeRabbit configuration file

**: # AGENTS.md - AI Agent Coding Guide

This guide is for AI coding agents working in the OpenClaude repository. Read it before changing code, and also follow CONTRIBUTING.md for contributor policy, PR expectations, review follow-up, and project scope.

Project Snapshot

OpenClaude is a coding-agent CLI for cloud and local model providers. It supports OpenAI-compatible APIs, Anthropic, Gemini, DeepSeek, Ollama, MCP, local backends, slash commands, tools, agents, and a React/Ink terminal UI.

The installed CLI runs on Node.js >=22.0.0. Bun is used for source builds, scripts, dependency management, and tests.

Work Style

  • Keep changes focused on one problem.
  • Prefer existing patterns in the file or nearby module.
  • Avoid unrelated formatting, renames, dependency changes, or broad rewrites.
  • Add or update tests when behavior changes.
  • Update docs when setup, commands, provider behavior, or user-facing behavior changes.
  • For new features, larger refactors, dependencies, or runtime changes, follow the issue-first guidance in CONTRIBUTING.md.

Stack And Conventions

  • TypeScript with strict mode and ESM imports.
  • React + Ink for terminal UI.
  • Bun lockfile and Bun scripts for development workflows.
  • Node runtime for the built CLI.
  • Python exists for legacy/local-provider helper code. Do not add new Python code or expand Python-based features unless a maintainer explicitly approves that direction.

Common libraries and patterns:

  • chalk for terminal color.
  • commander for CLI argument parsing.
  • execa for child processes.
  • Existing service, provider, settings, permission, and UI patterns over new abstractions.

Repository Map

  • src/commands/ - slash and CLI command implementations.
  • src/components/ - React/Ink UI components.
  • src/services/ - API, MCP, OAuth, wiki, voice, and other service integrations.
  • src/tools/ - tool implementations.
  • src/utils/ - shared utilities.
  • `src/integration...

Files:

  • src/__tests__/bugfixes.test.ts
  • src/utils/continuation.ts
{src/services/**/*.ts,src/utils/**/*.ts}

📄 CodeRabbit inference engine (AGENTS.md)

Use execa for child processes

Files:

  • src/utils/continuation.ts
🔇 Additional comments (2)
src/utils/continuation.ts (1)

16-24: LGTM!

Also applies to: 123-128

src/__tests__/bugfixes.test.ts (1)

138-157: LGTM!


📝 Walkthrough

Walkthrough

Expands CONTINUATION_SIGNALS in continuation.ts with two new regex patterns covering first-person-intent action verbs and present-progressive verb forms, and changes the completion-marker suppression check in analyzeContinuationIntent from full-text matching to last-sentence-only matching. A new test block validates these behaviors for issue #1707.

Changes

Continuation detection for non-Claude models

Layer / File(s) Summary
Expanded signals and last-sentence completion guard
src/utils/continuation.ts
CONTINUATION_SIGNALS gains a first-person-intent action-verb pattern and a present-progressive pattern. analyzeContinuationIntent now extracts the last sentence from lowerText and applies COMPLETION_MARKERS only to that sentence, preventing mid-text completion words from suppressing a later continuation intent.
Issue #1707 regression tests
src/__tests__/bugfixes.test.ts
New test block asserts shouldNudge is true for mid-text completion markers followed by continuation intent, for action verbs with first-person framing, and for present-progressive phrases; asserts shouldNudge is false when the last sentence is a completion marker.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

bug

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Title check ✅ Passed Title is concise, scoped, and directly matches the main changes: detecting non-Claude continuation intent and scoping the completion marker guard to the final sentence.
Description check ✅ Passed Description covers problem, fix, scope boundaries, and testing results with clear formatting. Missing explicit Testing checklist items but provides sufficient detail on testing performed.
Linked Issues check ✅ Passed PR directly addresses root causes 1 and 2 from #1707: scopes completion marker guard to final sentence and adds missing action verbs (process, download, compile, deploy, install, train, refactor) gated by intent framing.
Out of Scope Changes check ✅ Passed All changes are scoped to #1707 root causes 1 and 2. Causes 3, 4, and 5 are explicitly excluded as out-of-scope product/tuning decisions, which is appropriate.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Risk Surface Disclosed ✅ Passed PR touches only pure text analysis logic (continuation.ts regex patterns) and corresponding tests. No changes to auth, provider routing, permissions, network, background execution, startup/config,...
No Hidden Policy Change ✅ Passed PR contains only bug fixes to continuation detection heuristics; no hidden policy, trust-model, permission, routing-default, or telemetry changes. Broader product decisions (MAX_CONTINUATION_NUDGES...

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Gravirei

Copy link
Copy Markdown
Contributor

Hey — nice work isolating the bug. I ran the test cases you added against the implementation and 5 of 7 fail on main at HEAD 2f8aa50 (the CI green likely comes from a different snapshot). Adversarial probe with bun -e:

const { analyzeContinuationIntent } = await import('./src/utils/continuation.ts')
// expected true
analyzeContinuationIntent('The download is complete. Now I will install the dependencies').shouldNudge // false
analyzeContinuationIntent('Step one finished. I will now deploy the service').shouldNudge                  // false
analyzeContinuationIntent('Let me compile the project').shouldNudge                                       // false
analyzeContinuationIntent('I will now train the model').shouldNudge                                       // false
analyzeContinuationIntent('Now downloading the dataset').shouldNudge                                      // false
// expected false — these pass
analyzeContinuationIntent('Finished installing the packages. All set.').shouldNudge                      // false ✓
analyzeContinuationIntent('Downloaded the files and the migration is complete.').shouldNudge              // false ✓

Likely causes:

  1. Let me compile the project / I will now train the model — the new verb pattern matches, but the function then enters the hasTerminalPunctuation branch on line 100 and the strong-intent regex on line 102 (/\b(i (will|shall|need to|must|should|now)|let (me|us)|...)/i) rejects it. let me compile ends with a period, has no terminal \n/question mark, and the verb compile isn't in the strong-intent list — so it falls through to no nudge. Either include the new verbs in the strong-intent regex or short-circuit before the punctuation gate when the new verb pattern matches.

  2. Now downloading the dataset — present-progressive alone has no first-person intent and no terminal punctuation, so it never reaches shouldNudge: true. The new "present-progressive action statements" regex needs an explicit early-return (e.g., in step 2) that fires regardless of punctuation, since this is exactly the truncated-output case the comment claims to handle.

  3. The mid-text completion-marker scoping change looks correct in isolation but interacts badly with the existing late-window check on line 81 (lateText = lowerText.slice(-120)): for "The download is complete. Now I will install the dependencies" the late window starts mid-sentence, so the new regex is tested against "...complete. now i will install the dependencies" which does match — but then we still hit the same terminal-punctuation gate failure above.

Suggest: add the new verb list to the strong-intent regex on line 102, and promote the present-progressive match to its own early-return above the punctuation check. Then re-run the probes; all 5 should flip to true and the 2 suppression cases should still hold.

Happy to push a fix to your branch if you want — just say the word.

@jatmn

jatmn commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

this pr appears to also try to slip in before the original reporter landed his pr at #1713
please discuss and choose only 1 moving forward. neither pr will get a review until one is selected.

@0xghost42

Copy link
Copy Markdown
Contributor Author

Agreed — #1707 is @rayss868's report and #1713 is their own fix for it, so this should defer to that. Closing in favor of #1713 so review can focus on one.

@rayss868 — the cases I added in bugfixes.test.ts cover a few truncated-output shapes that @Gravirei's probe showed still come back shouldNudge: false on current main: present-progressive (Now downloading the dataset), bare imperative (Let me compile the project, I will now train the model), and the mid-sentence completion marker (The download is complete. Now I will install the dependencies). The gotcha Gravirei pinpointed: a matched verb still falls through the hasTerminalPunctuation + strong-intent gate, so the present-progressive case needs its own early return above that gate. Happy for you to lift those cases as regression tests if useful.

@0xghost42 0xghost42 closed this Jun 19, 2026
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.

Bug: Auto-continuation overly biased toward Claude-style output — breaks with non-Claude models

3 participants