Skip to content

ADFA-7286: AI Agent Claude 1.0.1: drop whitespace-only stop sequences - #193

Open
davidschachterADFA wants to merge 1 commit into
mainfrom
fix/ADFA-7286-claude-blank-stops
Open

davidschachterADFA wants to merge 1 commit into
mainfrom
fix/ADFA-7286-claude-blank-stops

Conversation

@davidschachterADFA

@davidschachterADFA davidschachterADFA commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

ADFA-7286: AI Agent Claude drops a whitespace-only stop sequence instead of sending it.

Problem. With AI Agent Claude as AI Core's backend, AI Code Suggestions never shows a suggestion: every request fails with "stop_sequences: each stop sequence must contain non-whitespace". AI Code Suggestions asks for a "\n\n" stop, and ClaudeRequestBuilder dropped only empty stop sequences, so the blank one reached the Messages API, which rejects the whole request.

Fix. ClaudeRequestBuilder filters stop sequences with isNotBlank(). A whitespace-only stop is dropped, so it no longer cuts the reply; the KDoc says so. No caller depends on one: the agent and tool paths set no stop sequences, and a whitespace-only stop could only ever fail the request.

This PR fixes the bug for any version of AI Code Suggestions. The companion PR #194 stops AI Code Suggestions sending stop sequences at all; either one alone fixes it.

Tests (ClaudeRequestBuilderTest, blocking path, as suggestions use):

  • givenStopSequences_whenBuilt_thenOnlyTheNonBlankOnesAreSent: "", "END" sends only END.
  • givenOnlyWhitespaceStopSequences_whenBuilt_thenNoStopSequencesAreSent: "\n\n", " " sends no stop_sequences key.
  • givenABlankAndARealStopSequence_whenBuilt_thenOnlyTheRealOneIsSent: AI Code Suggestions' old list "\n\n", "```" sends only the fence.

With the filter put back to isNotEmpty(), the two new tests fail.

Version. 1.0.1, versionCode 2. Open PR #191 (ADFA-7340) also takes AI Agent Claude to 1.0.1/2, and git merges the two without a conflict: whichever merges second must be bumped to 1.0.2/3 before it merges. #191's description says the same.

Checks at 4d77066: testDebugUnitTest (212 tests), assemblePlugin (no warnings) and addons check pass. The .cgp records revision 4d770662317c (not dirty).

Not covered. No device check against the real API: AI Agent Claude's base URL is fixed to api.anthropic.com, and no Claude key is available for the test phone. A tester with a key can check it with the Steps to QA on ADFA-7286.

The plan and its independent review are on ADFA-7286 (comment 41762).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vh2DAZWMkFWJh7CY7P4kCH

ClaudeRequestBuilder dropped only empty stop sequences, so a stop of "\n\n"
reached Anthropic's Messages API, which rejects whitespace-only stop
sequences with a 400. AI Code Suggestions sends exactly that, so every
suggestion request failed. The filter now drops blank stops, so a
whitespace-only stop no longer cuts the reply and no longer fails the call.

Tests cover the blocking path suggestions use, a list of only whitespace
stops (no stop_sequences key), and a whitespace stop beside a real one.
Version 1.0.1 (code 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZWMkFWJh7CY7P4kCH
@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Release notes: AI Agent Claude 1.0.1 (versionCode 2)

  • Fixes a request failure in AI Code Suggestions. Whitespace-only stop sequences, such as "\n\n", are no longer sent to the Messages API, which rejects them.
  • Filters stop sequences with isNotBlank() instead of isNotEmpty(). Blank entries are dropped. If no entries remain, the stop_sequences field is omitted, as before.
  • Updates the body documentation to state that dropped stop sequences do not truncate the reply.
  • Bumps versionName from 1.0.0 to 1.0.1 and versionCode from 1 to 2.

Risks and best-practice notes

  • No device test against the real Anthropic API was run. The base URL is fixed to api.anthropic.com, and no test key was available.
  • Callers that depend on whitespace-only stop sequences will see a behavior change. The author states that neither the agent nor tool paths depend on them.
  • Test coverage is limited to unit tests. Reverting to isNotEmpty() makes the two new tests fail, which confirms the tests cover the change.
  • The test stream flag changed from true to false. This change is not described in the objectives. Confirm that it is intended.
  • A concurrent change targets the same version. Whichever change merges second must bump the version to 1.0.2 or 1.0.3.
  • A companion change removes stop sequences from AI Code Suggestions. Either change alone fixes the bug. Confirm which fix is intended to ship.

The Claude plugin now omits whitespace-only stop sequences from request bodies. Tests cover whitespace-only and mixed stop sequences. The plugin version metadata changes to version code 2 and version name 1.0.1.

Changes: Claude stop-sequence handling

Layer / File(s) Summary
Stop-sequence filtering and validation
plugins/AI-Agent-Claude/build.gradle.kts, plugins/AI-Agent-Claude/src/main/kotlin/com/itsaky/androidide/plugins/aiagentclaude/backend/ClaudeRequestBuilder.kt, plugins/AI-Agent-Claude/src/test/kotlin/com/itsaky/androidide/plugins/aiagentclaude/backend/ClaudeRequestBuilderTest.kt
The request builder filters stop sequences with isNotBlank() and omits the field when no entries remain. Tests cover whitespace-only and mixed values. The Android version metadata changes to code 2 and name 1.0.1.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • appdevforall/addons#191: It sets the Claude plugin to version code 2 and version name 1.0.1, and edits Claude plugin KDoc comments.

Suggested reviewers: hal-eisen-adfa

Merge Risk: Minimal · up to 4d770

The Claude plugin now drops whitespace-only stop sequences, so requests from AI Code Suggestions no longer fail with an API error. The change is small, tested, and easy to revert. The only residual edge case is an unusual multi-line model reply, which is unlikely to matter in practice.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: ClaudeRequestBuilder now drops whitespace-only stop sequences, which fixes the Messages API rejection of the "\n\n" stop from AI Code Suggestions. It also carries the …
Description check Passed The description states the problem (the Messages API rejects a whitespace-only stop sequence such as "\n\n"), the fix (isNotBlank() filter and KDoc update), the three new or renamed tests, the version…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: ClaudeRequestBuilder now drops whitespace-only stop sequences, which fixes the Messages API rejection of the "\n\n" stop from AI Code Suggestions. It also carries the ticket ID and version bump, which are secondary but accurate to the changeset (build.gradle.kts version 1.0.1/versionCode 2). The title is concise and specific enough for a teammate scanning history.

Full details: Description check

Explanation

The description states the problem (the Messages API rejects a whitespace-only stop sequence such as "\n\n"), the fix (isNotBlank() filter and KDoc update), the three new or renamed tests, the version bump to 1.0.1/versionCode 2, the verification commands, and the untested device-level gap. It matches the raw summary and the PR objectives closely.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks each stop-string line,
And sends the words that still look fine.
Whitespace hops out of the request,
While tests confirm the filtered rest.
A fresh version joins the springtime quest.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: ffef2f18-1341-41b1-bb7f-17737c8031ec
Commits

Reviewing files that changed from the base of the PR and between 21c5c87 and 4d77066.

Files selected for processing: 3

  • plugins/AI-Agent-Claude/build.gradle.kts
  • plugins/AI-Agent-Claude/src/main/kotlin/com/itsaky/androidide/plugins/aiagentclaude/backend/ClaudeRequestBuilder.kt
  • plugins/AI-Agent-Claude/src/test/kotlin/com/itsaky/androidide/plugins/aiagentclaude/backend/ClaudeRequestBuilderTest.kt

Included review availability: This review used your included allowance. 3 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.

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.

1 participant