xonecas.io
64875
Mc

mini-coder / commit 380e081

revert: remove untestable image output feature

Reverts 22e5dd4 (responseModalities for Google models) and 69e87ad
(inline file generation from multimodal models).

No currently accessible models support image output — zen rejects
responseModalities on all three Gemini models (gemini-3-flash,
gemini-3-pro, gemini-3.1-pro) with 400 errors. Can be re-added
when an image-capable model becomes available for testing.

xonecas2026-03-22 380e0810a89c8152bdf4fa40ea431554d8a56cb3 parent c525802

11 files changed

src/agent/session-runner.ts+0−1
@@ -214,7 +214,6 @@ export class SessionRunner {
214214 ...(this.currentThinkingEffort
215215 ? { thinkingEffort: this.currentThinkingEffort }
216216 : {}),
217- cwd: this.cwd,
218217 });
219218
220219 const { inputTokens, outputTokens, contextTokens, newMessages } =
src/cli/stream-render.test.ts+0−20
@@ -349,24 +349,4 @@ describe("renderTurn", () => {
349349 const plain = stripAnsi(getCapturedStdout());
350350 expect(countOccurrences(plain, "$ printf ok")).toBe(1);
351351 });
352-
353- test("renders file-generated events as a one-liner", async () => {
354- captureStdout();
355-
356- await renderTurn(
357- eventsFrom([
358- {
359- type: "file-generated",
360- filePath: "/home/user/project/generated-1.png",
361- mediaType: "image/png",
362- },
363- done(),
364- ]),
365- new Spinner(),
366- );
367-
368- const plain = stripAnsi(getCapturedStdout());
369- expect(plain).toContain("image/png");
370- expect(plain).toContain("generated-1.png");
371- });
372352 });
src/cli/stream-render.ts+0−15
@@ -1,4 +1,3 @@
1-import { basename } from "node:path";
21 import * as c from "yoctocolors";
32 import { buildAbortMessages, isAbortError } from "../agent/agent-helpers.ts";
43 import type { CoreMessage } from "../llm-api/turn.ts";
@@ -138,20 +137,6 @@ export async function renderTurn(
138137 break;
139138 }
140139
141- case "file-generated": {
142- liveReasoning.finish();
143- content.flushOpenContent();
144- if (!quiet) {
145- spinner.stop();
146- if (renderedVisibleOutput) writeln();
147- writeln(
148- `${G.info} ${c.dim("file")} ${c.dim(event.mediaType)} ${c.dim("→")} ${basename(event.filePath)}`,
149- );
150- renderedVisibleOutput = true;
151- }
152- break;
153- }
154-
155140 case "turn-complete": {
156141 liveReasoning.finish();
157142 content.flushOpenContent();
src/llm-api/generated-files.test.ts+0−72
@@ -1,72 +0,0 @@
1-import { describe, expect, test } from "bun:test";
2-import { join } from "node:path";
3-import {
4- extensionFromMediaType,
5- saveGeneratedFile,
6-} from "./generated-files.ts";
7-
8-describe("extensionFromMediaType", () => {
9- test("maps common image types", () => {
10- expect(extensionFromMediaType("image/png")).toBe("png");
11- expect(extensionFromMediaType("image/jpeg")).toBe("jpg");
12- expect(extensionFromMediaType("image/gif")).toBe("gif");
13- expect(extensionFromMediaType("image/webp")).toBe("webp");
14- expect(extensionFromMediaType("image/svg+xml")).toBe("svg");
15- });
16-
17- test("extracts subtype for unknown types", () => {
18- expect(extensionFromMediaType("image/bmp")).toBe("bmp");
19- expect(extensionFromMediaType("image/tiff")).toBe("tiff");
20- expect(extensionFromMediaType("audio/mp3")).toBe("mp3");
21- });
22-
23- test("returns bin for unparseable types", () => {
24- expect(extensionFromMediaType("")).toBe("bin");
25- expect(extensionFromMediaType("invalid")).toBe("bin");
26- });
27-});
28-
29-describe("saveGeneratedFile", () => {
30- test("saves file to disk and returns path", async () => {
31- const dir = join(import.meta.dir, "../../.test-tmp-generated");
32- await Bun.write(join(dir, ".gitkeep"), "");
33-
34- const data = new Uint8Array([137, 80, 78, 71]); // PNG magic bytes
35- const filePath = await saveGeneratedFile(
36- { mediaType: "image/png", uint8Array: data },
37- dir,
38- );
39-
40- expect(filePath).toMatch(/generated-\d+\.png$/);
41- const file = Bun.file(filePath);
42- expect(await file.exists()).toBe(true);
43- expect(new Uint8Array(await file.arrayBuffer())).toEqual(data);
44-
45- // cleanup
46- const { rm } = await import("node:fs/promises");
47- await rm(dir, { recursive: true });
48- });
49-
50- test("increments counter to avoid collisions", async () => {
51- const dir = join(import.meta.dir, "../../.test-tmp-generated2");
52- await Bun.write(join(dir, ".gitkeep"), "");
53-
54- const data = new Uint8Array([0xff, 0xd8]); // JPEG magic
55- const path1 = await saveGeneratedFile(
56- { mediaType: "image/jpeg", uint8Array: data },
57- dir,
58- );
59- const path2 = await saveGeneratedFile(
60- { mediaType: "image/jpeg", uint8Array: data },
61- dir,
62- );
63-
64- expect(path1).not.toBe(path2);
65- expect(await Bun.file(path1).exists()).toBe(true);
66- expect(await Bun.file(path2).exists()).toBe(true);
67-
68- // cleanup
69- const { rm } = await import("node:fs/promises");
70- await rm(dir, { recursive: true });
71- });
72-});
src/llm-api/generated-files.ts+0−34
@@ -1,34 +0,0 @@
1-import { join } from "node:path";
2-
3-const MEDIA_TYPE_TO_EXT: Record<string, string> = {
4- "image/jpeg": "jpg",
5- "image/svg+xml": "svg",
6-};
7-
8-/** Derive a file extension from a MIME media type. */
9-export function extensionFromMediaType(mediaType: string): string {
10- if (MEDIA_TYPE_TO_EXT[mediaType]) return MEDIA_TYPE_TO_EXT[mediaType];
11- const slash = mediaType.indexOf("/");
12- if (slash === -1 || slash === mediaType.length - 1) return "bin";
13- return mediaType.slice(slash + 1);
14-}
15-
16-interface GeneratedFileData {
17- mediaType: string;
18- uint8Array: Uint8Array;
19-}
20-
21-let counter = 0;
22-
23-/** Save a generated file to disk, returning the absolute path. */
24-export async function saveGeneratedFile(
25- file: GeneratedFileData,
26- cwd: string,
27-): Promise<string> {
28- counter += 1;
29- const ext = extensionFromMediaType(file.mediaType);
30- const name = `generated-${counter}.${ext}`;
31- const filePath = join(cwd, name);
32- await Bun.write(filePath, file.uint8Array);
33- return filePath;
34-}
src/llm-api/turn-execution.test.ts+1−36
@@ -14,12 +14,9 @@ function chunksFrom(
1414
1515 async function collectEvents(
1616 chunks: Array<{ type?: string; [key: string]: unknown }>,
17- opts?: { cwd?: string },
1817 ): Promise<TurnEvent[]> {
1918 const events: TurnEvent[] = [];
20- for await (const event of mapFullStreamToTurnEvents(chunksFrom(chunks), {
21- ...(opts?.cwd ? { cwd: opts.cwd } : {}),
22- })) {
19+ for await (const event of mapFullStreamToTurnEvents(chunksFrom(chunks), {})) {
2320 events.push(event);
2421 }
2522 return events;
@@ -257,36 +254,4 @@ describe("mapFullStreamToTurnEvents", () => {
257254 { type: "text-delta", delta: " visible" },
258255 ]);
259256 });
260-
261- test("handles file stream chunks by saving to disk and yielding file-generated event", async () => {
262- const { join } = await import("node:path");
263- const { rm } = await import("node:fs/promises");
264- const dir = join(import.meta.dir, "../../.test-tmp-file-chunks");
265- await Bun.write(join(dir, ".gitkeep"), "");
266-
267- const events = await collectEvents(
268- [
269- {
270- type: "file",
271- file: {
272- mediaType: "image/png",
273- uint8Array: new Uint8Array([137, 80, 78, 71]),
274- base64: "",
275- },
276- },
277- ],
278- { cwd: dir },
279- );
280-
281- expect(events).toHaveLength(1);
282- expect(events[0]).toMatchObject({
283- type: "file-generated",
284- mediaType: "image/png",
285- });
286- const evt = events[0] as Extract<TurnEvent, { type: "file-generated" }>;
287- expect(evt.filePath).toMatch(/generated-\d+\.png$/);
288- expect(await Bun.file(evt.filePath).exists()).toBe(true);
289-
290- await rm(dir, { recursive: true });
291- });
292257 });
src/llm-api/turn-execution.ts+0−17
@@ -7,7 +7,6 @@
77 import type { FlexibleSchema, StepResult } from "ai";
88 import { dynamicTool, jsonSchema, type streamText } from "ai";
99 import { normalizeUnknownError } from "./error-utils.ts";
10-import { saveGeneratedFile } from "./generated-files.ts";
1110 import { isRecord } from "./history/shared.ts";
1211 import { isAnthropicModelFamily } from "./model-routing.ts";
1312 import {
@@ -371,7 +370,6 @@ export async function* mapFullStreamToTurnEvents(
371370 beforeTotalBytes: number;
372371 afterTotalBytes: number;
373372 }[];
374- cwd?: string;
375373 },
376374 ): AsyncGenerator<TurnEvent> {
377375 const toolCallTracker = new StreamToolCallTracker();
@@ -384,21 +382,6 @@ export async function* mapFullStreamToTurnEvents(
384382 yield { type: "context-pruned", ...rec };
385383 }
386384 }
387- // Handle file chunks from multimodal models (e.g. inline image generation)
388- if (originalChunk.type === "file" && opts.cwd) {
389- const fileData = originalChunk.file as
390- | { mediaType: string; uint8Array: Uint8Array }
391- | undefined;
392- if (fileData?.uint8Array) {
393- const filePath = await saveGeneratedFile(fileData, opts.cwd);
394- yield {
395- type: "file-generated",
396- filePath,
397- mediaType: fileData.mediaType,
398- };
399- continue;
400- }
401- }
402385 const prepared = toolCallTracker.prepare(originalChunk);
403386 const chunk = prepared.chunk;
404387 const route = textPhaseTracker.route(chunk);
src/llm-api/turn-provider-options.test.ts+0−46
@@ -1,46 +0,0 @@
1-import { describe, expect, test } from "bun:test";
2-
3-import { buildTurnProviderOptions } from "./turn-provider-options.ts";
4-
5-describe("buildTurnProviderOptions", () => {
6- test("sets responseModalities for google models", () => {
7- const result = buildTurnProviderOptions({
8- modelString: "google/gemini-2.5-flash",
9- thinkingEffort: undefined,
10- });
11- expect(result.providerOptions).toEqual({
12- google: { responseModalities: ["TEXT", "IMAGE"] },
13- });
14- });
15-
16- test("merges responseModalities with thinking config for google models", () => {
17- const result = buildTurnProviderOptions({
18- modelString: "google/gemini-2.5-flash",
19- thinkingEffort: "high",
20- });
21- expect(result.providerOptions).toMatchObject({
22- google: {
23- responseModalities: ["TEXT", "IMAGE"],
24- thinkingConfig: expect.any(Object),
25- },
26- });
27- });
28-
29- test("does not set responseModalities for non-google models", () => {
30- const result = buildTurnProviderOptions({
31- modelString: "anthropic/claude-sonnet-4-5",
32- thinkingEffort: undefined,
33- });
34- expect(result.providerOptions).toEqual({});
35- });
36-
37- test("sets responseModalities for zen google models", () => {
38- const result = buildTurnProviderOptions({
39- modelString: "zen/gemini-3.1-pro",
40- thinkingEffort: undefined,
41- });
42- expect(result.providerOptions).toEqual({
43- google: { responseModalities: ["TEXT", "IMAGE"] },
44- });
45- });
46-});
src/llm-api/turn-provider-options.ts+0−13
@@ -1,6 +1,5 @@
11 import { isRecord } from "./history/shared.ts";
22 import { isOpenAIGPT } from "./history-transforms.ts";
3-import { isGeminiModelFamily } from "./model-routing.ts";
43 import {
54 getCacheFamily,
65 getThinkingProviderOptions,
@@ -35,17 +34,6 @@ export function buildTurnProviderOptions(
3534
3635 const cacheFamily = getCacheFamily(modelString);
3736
38- const googleOpts = isGeminiModelFamily(modelString)
39- ? {
40- google: {
41- responseModalities: ["TEXT", "IMAGE"],
42- ...(isRecord(thinkingOpts?.google)
43- ? (thinkingOpts.google as object)
44- : {}),
45- },
46- }
47- : {};
48-
4937 const providerOptions = {
5038 ...(thinkingOpts ?? {}),
5139 ...(isOpenAIGPT(modelString)
@@ -58,7 +46,6 @@ export function buildTurnProviderOptions(
5846 },
5947 }
6048 : {}),
61- ...googleOpts,
6249 };
6350
6451 return {
src/llm-api/turn.ts+0−3
@@ -37,7 +37,6 @@ export async function* runTurn(options: {
3737 systemPrompt?: string;
3838 signal?: AbortSignal;
3939 thinkingEffort?: ThinkingEffort;
40- cwd?: string;
4140 }): AsyncGenerator<TurnEvent> {
4241 const {
4342 model,
@@ -47,7 +46,6 @@ export async function* runTurn(options: {
4746 systemPrompt,
4847 signal,
4948 thinkingEffort,
50- cwd,
5149 } = options;
5250
5351 const rawToolSet = buildToolSet(tools);
@@ -110,7 +108,6 @@ export async function* runTurn(options: {
110108
111109 for await (const event of mapFullStreamToTurnEvents(result.fullStream, {
112110 stepPruneQueue,
113- ...(cwd ? { cwd } : {}),
114111 onChunk: (streamChunk) => {
115112 if (
116113 streamChunk.type === "tool-call" ||
src/llm-api/types.ts+0−7
@@ -52,12 +52,6 @@ export interface TurnCompleteEvent {
5252 messages: CoreMessage[];
5353 }
5454
55-export interface FileGeneratedEvent {
56- type: "file-generated";
57- filePath: string;
58- mediaType: string;
59-}
60-
6155 export interface TurnErrorEvent {
6256 type: "turn-error";
6357 error: Error;
@@ -77,7 +71,6 @@ export type TurnEvent =
7771 | ToolCallStartEvent
7872 | ToolResultEvent
7973 | ContextPrunedEvent
80- | FileGeneratedEvent
8174 | TurnCompleteEvent
8275 | TurnErrorEvent;