Skip to content

chat: add image model and watermark settings, and give agents generated image paths - #342229

Merged
Justin Chen (justschen) merged 7 commits into
mainfrom
justinq/image-generation-model-setting
Oct 21, 2026
Merged

Justin Chen (justschen) merged 7 commits into
mainfrom
justinq/image-generation-model-setting

Conversation

@justschen

@justschen Justin Chen (justschen) commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Group image-generation preferences in Settings: retain the Off / GPT Image 2.5 Flare model dropdown and legacy-setting migration, and add the independent, default-off chat.copilot.imageGeneration.watermark setting moved from #342116. Also save each generated image in the session folder, where the Copilot CLI saves it, and give the agent its path.

Image model

  • Replace the chat.copilot.imageGeneration.enabled boolean with chat.copilot.imageGeneration.model. Each model option's markdown description lists its rates in the Settings dropdown details and settings.json completions.
  • Keep the existing consent defaults: GPT Image 2.5 Flare in Insiders, Off elsewhere.
  • Mirror the dropdown to the existing boolean imageGeneration Agent Host root key. A listed model sends true; off, retired IDs such as gpt-image-2.5-sunburst, and unknown values send false.
  • Migrate the legacy boolean (true to gpt-image-2.5-flare, false to off) only when the model setting is unset, and always remove the legacy key. Keep the legacy key registered as a deprecated application setting so migration also works while a non-default profile is active.
  • Keep model rates in the workbench dropdown rather than the model-agnostic host-key description. The existing Agent Host documentation update is preserved.

Watermark preference

  • Register the watermark checkbox alongside the model dropdown in imageGenerationConfigurationProperties. It is application-scoped, experimental, and defaults to false.
  • Mirror it independently to the imageGenerationWatermark root key. Changing the watermark preference does not enable image generation or change the selected model.
  • Pass both consent and watermark explicitly on SDK session creation and resume.
  • Synchronize live changes through the existing acknowledged options-update sequencer, including changes during launch. Failed updates remain unapplied and prevent sending until synchronization succeeds.
  • Retain the create/resume, live-update, launch-race, and failed-update regression coverage from the original watermark PR, and add coverage for the relocated Settings registration.

Labels are best-effort image-model behavior, not a guaranteed or deterministic overlay. Turning watermarking off does not remove labels already present in input images.

The wrapping batch-image grid is now isolated in #342116; no batch-renderer or carousel changes are included here.

Generated image paths

  • The runtime's image_generation tool tells the agent only an image_id. The Copilot CLI saves generated images in the session folder, but only for its "Open image" link, so its agents aren't told the path either.
  • CopilotAgentSession's post-tool-use hook now saves each generated image where the CLI does, <session folder>/images/image-<hash>.png, and adds a path: line after its image_id: line in the tool result, so the agent can copy or open the file.
  • Only images whose bytes match their image_id are saved. File names match the CLI's, pinned to its test vector, so a session opened in both reuses one file. A different file already at the path is left alone, and a deleted session folder is never recreated.

Why

The companion runtime change github/copilot-agent-runtime#27192 switches the served image model from GPT Image 2.5 Sunburst to GPT Image 2.5 Flare at unchanged rates. A model dropdown shows which model users opt into and what it costs. The runtime serves one image model and does not accept a per-session image-model selector, so this dropdown controls consent rather than selecting among runtime backends.

Watermarking is a separate preference and belongs with these image-generation settings rather than the batch-preview layout.

Agents asked to use a generated image, for example to copy it into the workspace, had only its image_id. They searched the session folder, found no file, and extracted the image from events.jsonl. Saving the image where the Copilot CLI already does and giving the agent that path lets it copy or open the file directly.

Notes for reviewers

  • Runtime dependency resolved: main now pins @github/copilot-sdk 1.0.24-preview.0 (agentHost: bump Copilot SDK to 1.0.24-preview.0 #342779), and this branch includes that bump. Its bundled runtime serves GPT Image 2.5 Flare (github/copilot-agent-runtime#27192) and includes the watermark option (github/copilot-agent-runtime#26998, with the CAPI side in github/copilot-api#39858). The integration and e2e results below ran against that bundled runtime.
  • The dropdown keeps the existing boolean host contract. Watermarking adds an independent boolean configuration key and forwards the supported runtime option; no new AHP RPC or event type is introduced.
  • The pinned SDK's ImageGenerationConfig declares both enabled and watermark as optional. A narrow local session-config interface makes both required, so every create and resume config states them and finalizing a session reads them without defaults. No generated-file edits or unsafe casts are needed.
  • The dropdown deliberately rejects unknown values: global configuration resolution validates the declared type, not enum membership, so an unlisted settings.json value must not enable whichever image model the runtime serves.
  • The deprecated legacy setting remains application-scoped because migration must read and remove it from the Default profile even while another profile is active. The model-setting choice and the active profile's settings remain intact.
  • Model labels are product names and are not localized; option descriptions are localized. Existing agent-host test titles that mention Sunburst are retained; the moved assertions exercise consent and watermark options, not a particular serving model.
  • The split preserves the existing dropdown and migration commits and adds watermark coverage on top, without rewriting the published branch.
  • Generated image paths need no runtime change: the runtime passes SDK callback hooks the full tool result, including the image bytes (declarative command hooks get only the text), and applies a hook's modifiedResult before the model sees it. So the file exists before the agent gets its path. This holds for the pinned 1.0.24-preview.0 and for the previous 1.0.23-preview.5.
  • Hook composition: toSdkHooks used to drop VS Code's own post-tool-use output. It now returns it, combined with plugin hooks' output, and plugin PostToolUse hooks see the result VS Code changed, as the runtime orders successive hooks.

How to test

  1. Open Settings and search chat.copilot.imageGeneration.model. Verify Off and GPT Image 2.5 Flare, including the Flare rates. Development builds default to Off.
  2. Set "chat.copilot.imageGeneration.enabled": true without the model setting, then reload. The legacy key should be removed and the model set to "gpt-image-2.5-flare"; false maps to "off". An existing model value must be preserved.
  3. Repeat with a non-default profile active and the legacy key in the Default profile's settings. Only the Default profile's relevant settings should migrate.
  4. Search chat.copilot.imageGeneration.watermark. Verify its default-off checkbox, toggle it while the model is Off, and confirm that the model remains Off.
  5. With the bundled runtime (leave chat.agentHost.copilot.runtimePath unset), verify newly created, resumed, and already-running Copilot sessions receive the consent and watermark values, including changes while a session is launching.
  6. With image generation separately enabled and account access available, generate/edit images with watermark on and off to assess best-effort visible labeling.
  7. Generate an image, then ask the agent to copy it into the workspace. The tool result should end with path: …/session-state/<session>/images/image-<hash>.png, and the agent should copy that file rather than search for it.

Validation

After merging main with the SDK 1.0.24-preview.0 bump (#342779), using its bundled runtime:

  • npm run typecheck-client and npm run build-fast — passed. ESLint on copilotSessionLauncher.ts, whose comment about the SDK types is updated — passed.

  • Image saving, hook composition, and agent session suites — 2,374 passing, one existing pending: the npm run test-node command under "Generated image paths" below, run with env -u COPILOT_HOME -u COPILOT_RUNTIME_PROVIDER_LIB.

  • Image model configuration, mirroring, and migration suites — 58 passing:

    env -u COPILOT_HOME -u COPILOT_RUNTIME_PROVIDER_LIB ./scripts/test.sh \
      --run vs/platform/agentHost/test/common/copilotCliConfig.test \
      --run vs/platform/agentHost/test/common/imageGenerationConfiguration.test \
      --run vs/platform/agentHost/test/common/agentHostConfigurationSync.test \
      --run vs/workbench/contrib/chat/test/browser/chatConfiguration.test \
      --run vs/workbench/contrib/chat/test/browser/imageGenerationSettingMigration.test
  • Provider integration — 5 passing, now with the GPT Image 2.5 Flare catalog entry from main:

    ./scripts/test-integration.sh --run src/vs/platform/agentHost/test/node/providerIntegration/copilotImageGeneration.integrationTest.ts
  • Agent Host e2e replay — all six suites passed (Conformance, Claude, Codex, Copilot, Copilot OTel, Copilot managed settings): 985 passing, none failing, 113 pending. This includes the plugin PostToolUse hook tests, which run through the changed hook composition:

    npm run test-agent-host-e2e -- --jobs 3
  • Manual: ran Code OSS built from this branch with only the bundled runtime (no runtime sources) and tried the changes; they worked.

On the separated image-settings branch, before the merge:

  • npm run build-fast -- --client-only — passed.

  • npm run typecheck-client — passed.

  • npm run precommit — passed on all ten staged files in the watermark move.

  • git diff --cached --check — passed before committing.

  • ESLint on all fourteen TypeScript files in the combined PR — passed:

    npm run eslint -- \
      src/vs/platform/agentHost/common/copilotCliConfig.ts \
      src/vs/platform/agentHost/common/imageGenerationConfiguration.ts \
      src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts \
      src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts \
      src/vs/platform/agentHost/node/copilot/copilotSessionWrapper.ts \
      src/vs/platform/agentHost/test/common/copilotCliConfig.test.ts \
      src/vs/platform/agentHost/test/common/imageGenerationConfiguration.test.ts \
      src/vs/platform/agentHost/test/node/copilotAgent.test.ts \
      src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts \
      src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts \
      src/vs/workbench/contrib/chat/browser/agentSessionsConfiguration.ts \
      src/vs/workbench/contrib/chat/browser/chat.shared.contribution.ts \
      src/vs/workbench/contrib/chat/test/browser/chatConfiguration.test.ts \
      src/vs/workbench/contrib/chat/test/browser/imageGenerationSettingMigration.test.ts
  • Watermark lifecycle, model configuration, configuration mirroring, and migration suites — 2,228 passing, one existing pending:

    env -u COPILOT_HOME -u COPILOT_RUNTIME_PROVIDER_LIB ./scripts/test.sh \
      --run vs/platform/agentHost/test/common/copilotCliConfig.test \
      --run vs/platform/agentHost/test/common/imageGenerationConfiguration.test \
      --run vs/platform/agentHost/test/node/copilotAgentSession.test \
      --run vs/platform/agentHost/test/node/copilotSessionLauncher.test \
      --run vs/platform/agentHost/test/node/copilotAgent.test \
      --run vs/platform/agentHost/test/common/agentHostConfigurationSync.test \
      --run vs/workbench/contrib/chat/test/browser/chatConfiguration.test \
      --run vs/workbench/contrib/chat/test/browser/imageGenerationSettingMigration.test
  • The new relocated-setting regression failed before the watermark property was registered in the shared image-settings module (undefined instead of the expected default-off, application-scoped property), then passed with the registration.

  • The existing non-default-profile migration regression runs the real migration against a WorkspaceService and checks both settings files. It remains passing and unchanged by the watermark move.

  • Earlier source-runtime watermark acceptance confirmed the real VS Code setting to runtime header to CAPI path without local prompt injection. That was before this split, using a runtime built from source.

Generated image paths, before the merge:

  • npm run typecheck-client, npm run valid-layers-check, and npm run precommit on the staged change — passed. ESLint on the eight changed TypeScript files — passed.

  • Image saving, hook composition, and agent session suites — 2,326 passing, one existing pending:

    npm run test-node -- \
      --run src/vs/platform/agentHost/test/node/copilotGeneratedImages.test.ts \
      --run src/vs/platform/agentHost/test/node/copilotPluginConverters.test.ts \
      --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts \
      --run src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts \
      --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts
  • Provider integration against the bundled runtime — 5 passing. The new test has the synthetic model call the real image_generation tool, the synthetic /v1/images/generations return a PNG, and checks the saved file and the path the model receives:

    ./scripts/test-integration.sh --run src/vs/platform/agentHost/test/node/providerIntegration/copilotImageGeneration.integrationTest.ts
  • With the old hook composition restored, the integration test fails because the model receives only the image_id; three deliberate breakages (dropping VS Code's hook output, saving outside the CLI's images folder, saving without telling the agent) each failed unit tests, and the code was restored.

Not exercised in this update: the combined Settings UI and live image generation against the real image service. No paid image-generation requests were made.

The Copilot runtime now serves GPT Image 2.5 Flare instead of GPT Image
2.5 Sunburst (github/copilot-agent-runtime#27192), at unchanged rates.
Replace the chat.copilot.imageGeneration.enabled boolean with a
chat.copilot.imageGeneration.model dropdown offering Off and GPT Image
2.5 Flare. Each model's option lists its rates in its markdown
description, so the Settings dropdown and settings.json completions
show the cost of the model being chosen.

The runtime serves one image model and its SDK session options take no
model, so the dropdown still mirrors the boolean imageGeneration root
key, and older and remote Agent Hosts need no change. Only a listed
model turns the key on. Off, retired models such as
gpt-image-2.5-sunburst, and any other value turn it off, because the
mirror checks only the setting's type and an unknown string must not
enable whatever model the runtime serves. The host key's description
no longer names a model: it is published to AHP clients and cannot
know which model the runtime serves.

The legacy boolean migrates to the dropdown (true to Flare, false to
Off) unless the new setting is already set, and is always removed.
Defaults are unchanged: Flare in Insiders, Off elsewhere.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 04:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Migration can leave the legacy setting behind when a non-default profile is active, allowing stale preferences to be reapplied.

1 open issue
What changed in this PR

Replaces the image-generation toggle with a model dropdown while preserving the Agent Host’s boolean contract.

Changes:

  • Adds Off and GPT Image 2.5 Flare options with pricing descriptions.
  • Migrates the legacy boolean without overwriting an explicit model selection.
  • Updates documentation and tests for defaults, migration, and value validation.
File Description
src/​vs/​workbench/​contrib/​chat/​test/​browser/​chatConfiguration.test.ts Tests legacy-setting migration.
src/​vs/​workbench/​contrib/​chat/​browser/​chat.shared.contribution.ts Registers the model dropdown.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessionsConfiguration.ts Adds legacy-setting migration.
src/​vs/​platform/​agentHost/​test/​common/​imageGenerationConfiguration.test.ts Tests dropdown metadata, defaults, and boolean conversion.
src/​vs/​platform/​agentHost/​common/​imageGenerationConfiguration.ts Defines model options, pricing, and conversion helpers.
src/​vs/​platform/​agentHost/​common/​copilotCliConfig.ts Adds the model setting ID and generalizes host descriptions.
src/​vs/​platform/​agentHost/​AGENTS.md Documents model selection and host mirroring.

Review effort: Balanced

With a non-default profile active, VS Code reads and writes a setting in
the default profile's settings only if the registry knows the setting is
application-scoped. Unregistering chat.copilot.imageGeneration.enabled
hid its value there, so the migration never ran: the user's choice was
ignored, and the new setting fell back to its default, which is GPT
Image 2.5 Flare in Insiders even for users who had turned image
generation off.

Keep the legacy boolean registered as a deprecated application setting.
The Settings editor hides it unless it is configured, and the migration
can now read it from, and remove it in, the default profile's settings.
A test with a non-default profile checks the actual settings files.

Co-authored-by: Copilot <[email protected]>
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Base: b8ab8d38 Current: 6e3c5b09

No screenshot changes.

Move the independent watermark setting from #342116 into the image settings PR. Keep the model dropdown and legacy profile migration intact, and register the watermark next to them with its existing default-off semantics.

Preserve create, resume, and acknowledged live-update wiring and regression coverage. Add a configuration regression for the relocated setting.

Co-authored-by: Copilot <[email protected]>
Justin Chen (justschen) added a commit that referenced this pull request Oct 18, 2026
Keep this branch focused on the batched image preview grid. Move the independent watermark preference and its create, resume, and live-update coverage to #342229.

Co-authored-by: Copilot <[email protected]>
Justin Chen (justschen) added a commit that referenced this pull request Oct 18, 2026
Keep the already-validated VS Code main baseline and its image rendering performance fixes while preserving the published PR history. The final feature diff contains only the four batch-grid files; watermark settings now live in #342229.

Co-authored-by: Copilot <[email protected]>
@justschen Justin Chen (justschen) changed the title chat: pick the image generation model from a dropdown chat: add image model and watermark settings Oct 18, 2026
Justin Chen (justschen) added a commit that referenced this pull request Oct 18, 2026
* chat: expose opt-in image watermark setting

Add a default-off user setting and mirror it to Copilot Agent Host sessions on create, resume, and acknowledged live updates without changing image-generation consent.

Co-authored-by: Copilot <[email protected]>

* chat: wrap image batch previews with stable row heights

Keep the selected main image above responsive thumbnail rows with at most five items. Reserve row height while mixed-size images arrive, preserve each tile's natural proportions, and leave unused width outside the tiles rather than cropping or adding bars.

Preserve selection and focus, add vertical keyboard navigation, and cover progressive loading with renderer tests and Component Explorer fixtures.

Co-authored-by: Copilot <[email protected]>

* chat: move watermark settings to the image model PR

Keep this branch focused on the batched image preview grid. Move the independent watermark preference and its create, resume, and live-update coverage to #342229.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
…ion-model-setting

Resolves conflicts with main:
- copilotSessionLauncher.ts: keeps main's sandbox-aware session opening
  (_openWithSandboxConfig and SandboxAwareSessionConfig), and bases that
  config on ICopilotSessionConfig so the image generation watermark keeps
  its type through create, resume and finalize.
- copilotAgentSession.test.ts: keeps main's duringLaunch hook and passes
  the watermark to CopilotSessionWrapper.
- chat.shared.contribution.ts: takes main's copilotCliConfig imports,
  without the image generation symbols that now come from
  imageGenerationConfiguration.ts.

Co-authored-by: Copilot <[email protected]>
The runtime's image_generation tool tells the agent only an image_id, so
an agent asked to put the image in the workspace searched the session
folder, found no file, and extracted the image from events.jsonl. The
Copilot CLI saves generated images in the session folder, but only for
its "Open image" link, so its agents aren't told the path either.

CopilotAgentSession's post-tool-use hook now saves each generated image
where the CLI does, <session folder>/images/image-<hash>.png, and adds a
"path:" line after its "image_id:" line in the tool result. The runtime
passes SDK callback hooks the full tool result, including the image
bytes, and applies modifiedResult before the model sees it, so the file
exists when the agent gets its path. Only images whose bytes match their
image_id are saved; names match the CLI's (pinned to its test vector), so
a session opened in both reuses one file; a different file at the path
is left alone; and a deleted session folder is never recreated.

toSdkHooks now returns VS Code's own post-tool-use output instead of
dropping it, combined with plugin hooks' output, and plugin hooks see the
result VS Code changed, as the runtime orders successive hooks.

A provider integration test has the synthetic model call the real
runtime's image tool and checks the saved file and the path the model
receives; without this change the model gets only the image_id.

Co-authored-by: Copilot <[email protected]>
@justschen Justin Chen (justschen) changed the title chat: add image model and watermark settings chat: add image model and watermark settings, and give agents generated image paths Oct 20, 2026
…ion-model-setting

Picks up the Copilot SDK 1.0.24-preview.0 bump (#342779), whose bundled
runtime serves GPT Image 2.5 Flare.

Co-authored-by: Copilot <[email protected]>
The pinned Copilot SDK now declares the watermark option, so the old note
about it missing from the SDK type projection was stale. The local interface
only makes both options required for the finalize step.

Co-authored-by: Copilot <[email protected]>
@justschen
Justin Chen (justschen) marked this pull request as ready for review October 21, 2026 00:46
@justschen
Justin Chen (justschen) enabled auto-merge (squash) October 21, 2026 00:48
@justschen
Justin Chen (justschen) merged commit aac38c0 into main Oct 21, 2026
58 checks passed
@justschen
Justin Chen (justschen) deleted the justinq/image-generation-model-setting branch October 21, 2026 01:18
@vs-code-engineering vs-code-engineering Bot added this to the 1.144.0 milestone Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants