diff --git a/plugins/AI-Agent-Claude/build.gradle.kts b/plugins/AI-Agent-Claude/build.gradle.kts index bd5805663..bc046b328 100644 --- a/plugins/AI-Agent-Claude/build.gradle.kts +++ b/plugins/AI-Agent-Claude/build.gradle.kts @@ -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 { diff --git a/plugins/AI-Agent-Claude/src/main/kotlin/com/itsaky/androidide/plugins/aiagentclaude/backend/ClaudeRequestBuilder.kt b/plugins/AI-Agent-Claude/src/main/kotlin/com/itsaky/androidide/plugins/aiagentclaude/backend/ClaudeRequestBuilder.kt index 27ad8b86d..2ea74bb93 100644 --- a/plugins/AI-Agent-Claude/src/main/kotlin/com/itsaky/androidide/plugins/aiagentclaude/backend/ClaudeRequestBuilder.kt +++ b/plugins/AI-Agent-Claude/src/main/kotlin/com/itsaky/androidide/plugins/aiagentclaude/backend/ClaudeRequestBuilder.kt @@ -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 diff --git a/plugins/AI-Agent-Gemini/build.gradle.kts b/plugins/AI-Agent-Gemini/build.gradle.kts index 1c097631a..894d05de4 100644 --- a/plugins/AI-Agent-Gemini/build.gradle.kts +++ b/plugins/AI-Agent-Gemini/build.gradle.kts @@ -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 { diff --git a/plugins/AI-Agent-Gemini/src/main/kotlin/com/itsaky/androidide/plugins/aiagentgemini/backend/GeminiBackend.kt b/plugins/AI-Agent-Gemini/src/main/kotlin/com/itsaky/androidide/plugins/aiagentgemini/backend/GeminiBackend.kt index a858f48f8..990e0487e 100644 --- a/plugins/AI-Agent-Gemini/src/main/kotlin/com/itsaky/androidide/plugins/aiagentgemini/backend/GeminiBackend.kt +++ b/plugins/AI-Agent-Gemini/src/main/kotlin/com/itsaky/androidide/plugins/aiagentgemini/backend/GeminiBackend.kt @@ -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 + * 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.