@opencode/ai 0.0.0-dev-21083 → 0.0.0-dev-21085

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ import { Auth } from "../route/auth.js";
5
5
  import { Endpoint } from "../route/endpoint.js";
6
6
  import { Protocol } from "../route/protocol.js";
7
7
  import { HttpTransport, } from "../route/transport/index.js";
8
- import { AIError, LLMEvent, Usage, } from "../schema/index.js";
8
+ import { AIError, InvalidProviderOutputError, LLMEvent, Usage, } from "../schema/index.js";
9
9
  import { classifyProviderFailure } from "../provider-error.js";
10
10
  import { Media } from "../media.js";
11
11
  import { JsonObject, knownString, lenient, optionalArray, optionalNull, ProviderShared } from "./shared.js";
@@ -534,6 +534,16 @@ const step = (state, event) => {
534
534
  usage: event.usageMetadata ?? state.usage,
535
535
  finishReason: candidate?.finishReason ?? state.finishReason,
536
536
  };
537
+ // Gemini sporadically ends a valid request with MALFORMED_RESPONSE; continuing or resending it recovers.
538
+ if (candidate?.finishReason === "MALFORMED_RESPONSE")
539
+ return Effect.fail(new AIError({
540
+ reason: new InvalidProviderOutputError({
541
+ route: state.route,
542
+ message: `Gemini stopped with ${candidate.finishReason}`,
543
+ body: ProviderShared.encodeJson(event),
544
+ classification: "incomplete-stream",
545
+ }),
546
+ }));
537
547
  if (candidate?.finishReason && mapFinishReason(candidate.finishReason, state.hasToolCalls) === "error")
538
548
  return Effect.fail(ProviderShared.eventError(state.route, `Gemini stopped with ${candidate.finishReason}`, ProviderShared.encodeJson(event)));
539
549
  if (!candidate?.content)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-dev-21083",
3
+ "version": "0.0.0-dev-21085",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@clack/prompts": "1.0.0-alpha.1",
36
36
  "@effect/platform-node": "4.0.1",
37
- "@opencode/http-recorder": "0.0.0-dev-21083",
37
+ "@opencode/http-recorder": "0.0.0-dev-21085",
38
38
  "@tsconfig/bun": "1.0.9",
39
39
  "@types/bun": "1.4.0",
40
40
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -44,7 +44,7 @@
44
44
  "@aws-sdk/credential-providers": "3.1057.0",
45
45
  "@smithy/eventstream-codec": "4.2.14",
46
46
  "@smithy/util-utf8": "4.2.2",
47
- "@opencode/schema": "0.0.0-dev-21083",
47
+ "@opencode/schema": "0.0.0-dev-21085",
48
48
  "aws4fetch": "1.0.20",
49
49
  "effect": "4.0.1",
50
50
  "google-auth-library": "10.5.0"