Skip to content

feat(cli): images on any turn and ACP image blocks (#559) - #563

Merged
ajianaz merged 1 commit into
developfrom
feat/559-images-any-turn
Nov 11, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/559-images-any-turn

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What

Images can now ride on any user message, not only the first one:

  • tole chat has /image <path|data-url>. It queues an image for the next message. /image on its own lists the queue and /image clear empties it.
  • The TUI host (TuiSession) has a pending-image queue that the next run_turn takes. feat(tui): handle terminal paste and attach images (paste, path, optional clipboard) #560 will drive it from tole-tui.
  • tole acp accepts ACP image content blocks and advertises promptCapabilities.image. An image-only prompt now runs instead of failing with "missing prompt".

Closes #559

Why

The core (run_turn_with_images) already takes images per turn, so the first-message-only limit was in the hosts. In a long chat or the TUI you could not show the model a screenshot halfway through. ACP dropped image blocks and rejected an image-only prompt, so a pasted image from an editor got nothing.

Image-tool decision (owner): no model-callable image tool for now. Images stay user-supplied. Tool results are text in the OpenAI-compatible format, so a tool would need an attributed-message mechanism plus its own threat-model entry. The decision is recorded on #559 and in docs/threat-model.md. It will be revisited in a follow-up issue if a concrete need comes up.

Changes

  • Core: verified, one small change. Images are already recorded per user message and rebuilt per message on the wire. The one change in tole-core/src/openai.rs is that an image-only user message no longer sends an empty text part.
  • turn_runner (additive):
    • run_turn_on_with_images and run_turn_with_images. The existing run_turn_on and run_turn_with delegate to them with &[].
    • resolve_image(spec): one spec, same jail, size cap and sniffing as --image.
    • resolve_inline_image(base64): the same spill path as a CLI data: URL. It refuses an oversize payload before decoding it.
    • inline_images_supported()
  • session_host (additive): run_session_turn_with_images; run_session_turn delegates to it. Memory recall is skipped when the prompt has no text.
  • ACP (acp.rs):
    • New prompt_content() turns text blocks into the prompt text and image blocks into images through resolve_inline_image.
    • The client's mimeType is not trusted: the bytes are sniffed.
    • The optional uri is never read, so no client-named path reaches the filesystem.
    • One bad image refuses the whole prompt instead of being dropped silently.
    • Audio, resource and resource_link blocks are still ignored.
    • initialize now advertises promptCapabilities: {image: <spill dir exists>, audio: false, embeddedContext: false}. Per the ACP spec, image blocks require the image prompt capability. A code comment quotes the spec, checked 2026-11-11.
  • chat (main.rs):
    • New /image line command.
    • When a typed message is not recorded (dropped-message path), its images stay queued.
    • The startup line and --image help mention /image.
  • tui_host.rs:
    • New field Inner.pending_images.
    • New methods: attach_image(spec) -> Result<ImageRef, String>, attach_image_ref, pending_images, clear_pending_images.
    • run_turn takes the queue. If the message never reached the log (a parked turn that did not settle, or a provider build error), the images go back to the front of the queue.
  • Docs:

Testing

  • cargo fmt --all -- --check: clean.
  • cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo check -p tole-cli --no-default-features and cargo check -p tole-cli --no-default-features --features shell-tools --tests: clean.
  • cargo test --workspace: 1224 passed, 0 failed.
  • cargo test -p tole-cli --no-default-features --test images_any_turn_e2e: passes. The chat test runs in the bare profile; the ACP test needs shell-tools.
  • New tests:
    • turn_runner::each_turn_records_its_own_images: the acceptance test. The second turn's message records its own references and the first records none.
    • turn_runner::an_oversize_inline_image_is_refused_before_decoding
    • tui_host::pending_images_ride_on_the_next_message_only: the queue is taken by one message, and a message that was not recorded keeps its images.
    • acp::tests::prompt_content_* (3 tests): text/image mapping, ignored blocks, image-only accepted, empty prompt refused, bad image refused.
    • openai::an_image_only_user_message_sends_no_empty_text_part
    • tests/images_any_turn_e2e.rs, using the real binary and a recording mock provider:
      • chat: /image on a later message. A path outside the jail is refused, the second message records the image and only that request carries it on the wire.
      • ACP over the real loop: the capability is advertised. An image-only prompt runs, is sniffed as PNG despite a wrong mimeType, the uri is ignored and the file is spilled under $CODECORA_HOME/tole/images. A text+audio prompt runs with the audio ignored. An audio-only prompt and a non-image block are both refused. No base64 blob ends up in the log.
  • Mutation checks: each mutation below was applied, the named tests failed, and the code was restored.
    • Dropping images in turn_runner::run_turn_with_images: each_turn_records_its_own_images and the ACP e2e test fail.
    • Not queuing in chat /image: the chat e2e test fails.
    • Clearing instead of restoring the TUI queue: the tui_host test fails.
    • Restoring the old "image-only = missing prompt" rule: the ACP e2e test and prompt_content_accepts_image_only_and_refuses_empty fail.
  • cora review --staged was not run: cora is not installed in this environment. I reviewed the staged diff by hand instead, focusing on the jail and size cap for ACP-supplied images, type sniffing, the client uri never being read, and the error paths. CI Cora Review is the gate.
  • Spec check: the ACP spec (agentclientprotocol.com, protocol/initialization and protocol/content) was read on 2026-11-11 and quoted in acp.rs. Not changed here: the spec's baseline says agents MUST support resource_link blocks in prompts. tole ignored them before this PR and still does, so a prompt with only a resource_link is still refused as "missing prompt".

Chat queues images for any later message with /image, the TUI host keeps
a pending-image queue taken by the next turn, and ACP maps image content
blocks onto the spill-and-reference path, advertises
promptCapabilities.image and runs image-only prompts. An image-only user
message sends no empty text part. No model-callable image tool, by
decision; threat model and README updated.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 8058ce9 into develop Nov 11, 2026
19 of 20 checks passed
@ajianaz
ajianaz deleted the feat/559-images-any-turn branch November 11, 2026 04:10
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.

feat(core,cli): images on any turn, ACP image blocks, and a decision on an image-reading tool

2 participants