Repository navigation
feat(core): make image generation a Code Mode tool - #60086
rekram1-node wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
The move into Code Mode works as described. tools.image.generate shows up in the catalog unpinned, appears and disappears with image models, and its effective name stays image_generate, so permission rules, background jobs and restart recovery are unchanged. In packages/core the image-generate, codemode and session-execution tests pass (74) and typecheck:tsc is clean.
Public API: unchanged. The model-facing tool moves from image_generate to tools.image.generate, but the permission action, job type and config keys stay the same.
One concern, inline: called through Code Mode, the agent only gets the structured output ({ path, model }). The "started in the background, you'll be notified, don't poll" text and the model-fallback note are lost, and path has no extension.
| name, | ||
| options: { codemode: false }, | ||
| name: "generate", | ||
| options: { namespace, codemode: true }, |
There was a problem hiding this comment.
Now that this runs through Code Mode, the agent only gets output back: Code Mode returns executed.output whenever it is defined and ignores content. I instrumented the new test and the execute result is just { "path": ".../image_<id>", "model": "test/painter" }.
That drops three things the direct tool used to tell the agent:
- that the job is still running in the background and a notice will follow (without it, the agent may try to
readthe file right away); - that
pathhas no extension yet; - the
resolved.notesaying the configured model was unavailable and another was used.
The catalog description partly covers the first point, but the fallback note has no other route to the agent. One fix would be to add these to Output, e.g. a status: "started" field and an optional note.
|
Closing this. The image tool is now opt-in (experimental.image_generate) and stays a direct tool. In benchmarks, Code Mode hid the background-job behavior from agents, and they polled for the file much more often. |
image_generatewas a direct tool, offered next toexecuteon every request where an image model exists. I moved it into Code Mode, unpinned, so it sits in the catalog until an agent needs it, and the prompt stays smaller on every turn that doesn't generate images.It gets its own
imagenamespace rather thanopencode, sinceopencodeis about managing OpenCode itself (sessions, worktrees, models). That also keeps it clear of the internal plugin'sopencode_image_generate.The tool's effective name stays
image_generate, so permission rules ("image_generate": "deny"), background jobs and restart recovery are unchanged. It's still registered only while some connected provider has an image model, and it re-checks when the catalog changes. With Code Mode denied it falls back to a directimage_generatetool like the other Code Mode tools.Verification
packages/coretest/tool-image-generate.test.ts(15 pass, twice): the tool shows up in the Code Mode catalog asimage.generate, isn't pinned and isn't a direct tool; it appears and disappears with image models; a new test callstools.image.generatethroughexecute. The other tests run it with Code Mode denied, where it's direct.test/lib/tool.ts'sexecuteTooltakes optional permissions for that.session-execution,codemodeandtool-scheduletests pass (45).bun run typecheck:tscinpackages/coreandbun run checkpass.