Skip to content
4 changes: 2 additions & 2 deletions plugins/AI-Agent-Claude/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = "com.itsaky.androidide.plugins.aiagentclaude"
minSdk = 33
targetSdk = 36
versionCode = 1
versionName = "1.0.0"
versionCode = 2
versionName = "1.0.1"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ internal object ClaudeRequestBuilder {
* The caller hands tool results back as ordinary text — a USER turn wrapping each result, or
* a TOOL turn — and never the assistant `tool_use` block they answer, so they are sent as user
* text rather than as `tool_result` blocks, which the API rejects without a matching call.
* That leaves runs of same-role turns, which are merged into one; blank turns are dropped,
* since the API refuses an empty text block. SYSTEM turns join the top-level system prompt:
* the API has no system role inside `messages[]` that every model accepts.
* Runs of same-role turns still occur and are merged into one: AI Core stores no assistant turn
* for a reply with no text, which before ADFA-7340 includes a native call made with no prose,
* and a restored chat can start with two user turns. Blank turns are dropped, since the API
* refuses an empty text block. SYSTEM turns join the top-level system prompt: the API has no
* system role inside `messages[]` that every model accepts.
*
* @param history the conversation so far, oldest first
* @param prompt the current user turn, appended last
Expand Down
4 changes: 2 additions & 2 deletions plugins/AI-Agent-Gemini/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = "com.itsaky.androidide.plugins.aiagentgemini"
minSdk = 33
targetSdk = 36
versionCode = 2
versionName = "1.1.0"
versionCode = 3
versionName = "1.1.1"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,15 @@ class GeminiBackend(
/**
* Builds the `contents[]` array for a multi-turn request.
*
* Consecutive same-role turns are merged into one content, because the transcript no longer
* always alternates: the agent loop drops an ASSISTANT turn that carried only a native call
* and no prose, leaving the user message and the tool results it produced adjacent.
* Consecutive same-role turns are merged into one content, because the history a caller passes
* does not always alternate. AI Core's agent loop stores no assistant turn for a reply with no

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

MINOR: The reworded comment says AI Core stores no assistant turn for a reply with no text and no call, which reads as if a call-only reply is stored; at this PR's head and on main it is not.

AgentLoop.kt:300 only stores a turn when historyText is non-blank, and a native call with no prose has a blank one, so the call-only reply is also dropped and the user message and tool results sit adjacent. Only #188 (c3eed33, bareCallTurn) changes that. The PR body says it merges any time and the comments hold either way, but before #188 lands this comment omits the most common cause of repeated roles, and a reader will think the merge is needed only for the rare cases.

Fix: merge after #188, or add 'and, until addons #188, a reply that carried only a native call' to the comment.


Generated by Claude Code

* text, and sends tool results as a user turn. So the results of a native call made with no
* prose follow the previous user turn directly, unless AI Core stores a turn naming the call
* (it does from ADFA-7340 on; older versions don't). The same happens when it asks the model
* to go on, or for a required tool, after an empty reply. A chat AI Core restores from its
* messages leaves out an agent reply that had no text or never finished, and starts with the
* compaction summary as a user turn. SYSTEM and TOOL turns, which other callers may send, also
* go as user turns here.
*
* The system prompt is NOT one of these turns: [buildRequestJson] sends it as the request's
* `systemInstruction`, where the API privileges it over anything a later turn says.
Expand Down
Loading