@opencode-ai/ai
Advanced tools
@@ -29,2 +29,5 @@ import { Effect, Schema } from "effect"; | ||
| }; | ||
| // Gemini 3 accepts media nested inside function responses; matched Gemini 2.5 variants reject it, | ||
| // so their tool-result attachments lower as a separate user turn instead. | ||
| const routesLegacyToolMedia = (modelID) => /gemini-2[.-]5(?:[.-]|$)/i.test(modelID); | ||
| // ============================================================================= | ||
@@ -201,3 +204,13 @@ // Request Body Schema | ||
| const contents = []; | ||
| const legacyToolMedia = routesLegacyToolMedia(request.model.id); | ||
| let pendingMedia; | ||
| const flushMedia = () => { | ||
| if (!pendingMedia) | ||
| return; | ||
| contents.push({ role: "user", parts: [{ text: "Attached media from tool result:" }, ...pendingMedia] }); | ||
| pendingMedia = undefined; | ||
| }; | ||
| for (const message of request.messages) { | ||
| if (message.role !== "tool") | ||
| flushMedia(); | ||
| if (message.role === "system") { | ||
@@ -283,2 +296,4 @@ const part = yield* ProviderShared.wrappedSystemUpdate("Gemini", message); | ||
| } | ||
| if (legacyToolMedia && media.length > 0) | ||
| (pendingMedia ??= []).push(...media); | ||
| parts.push({ | ||
@@ -292,3 +307,3 @@ functionResponse: { | ||
| }, | ||
| parts: media.length > 0 ? media : undefined, | ||
| parts: legacyToolMedia || media.length === 0 ? undefined : media, | ||
| }, | ||
@@ -305,2 +320,3 @@ }); | ||
| } | ||
| flushMedia(); | ||
| return contents; | ||
@@ -307,0 +323,0 @@ }); |
+3
-3
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "version": "0.0.0-dev-17825", | ||
| "version": "0.0.0-dev-17828", | ||
| "name": "@opencode-ai/ai", | ||
@@ -33,3 +33,3 @@ "type": "module", | ||
| "@effect/platform-node": "4.0.0-rc.110", | ||
| "@opencode-ai/http-recorder": "0.0.0-dev-17825", | ||
| "@opencode-ai/http-recorder": "0.0.0-dev-17828", | ||
| "@tsconfig/bun": "1.0.9", | ||
@@ -43,3 +43,3 @@ "@types/bun": "1.3.13", | ||
| "@smithy/util-utf8": "4.2.2", | ||
| "@opencode-ai/schema": "0.0.0-dev-17825", | ||
| "@opencode-ai/schema": "0.0.0-dev-17828", | ||
| "aws4fetch": "1.0.20", | ||
@@ -46,0 +46,0 @@ "effect": "4.0.0-rc.110", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1186061
0.07%27346
0.06%+ Added
- Removed