summaryrefslogtreecommitdiffhomepage
path: root/.rules/plan/09-15-reject-image-document.md
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-04-30 20:24:33 +0900
committerAdam Malczewski <[email protected]>2026-04-30 20:24:33 +0900
commit262aa7395c50b449ce0a897f28b1e33c319f5dc7 (patch)
tree2ccc7c7f6402e76aea6b8788046215e82650fdfc /.rules/plan/09-15-reject-image-document.md
parent1e7a273bda744f93f230d21df895b54d2a81ce15 (diff)
downloaddispatch-adapter-minimax-main.tar.gz
dispatch-adapter-minimax-main.zip
add plan to updateHEADmain
Diffstat (limited to '.rules/plan/09-15-reject-image-document.md')
-rw-r--r--.rules/plan/09-15-reject-image-document.md109
1 files changed, 109 insertions, 0 deletions
diff --git a/.rules/plan/09-15-reject-image-document.md b/.rules/plan/09-15-reject-image-document.md
new file mode 100644
index 0000000..6b9459f
--- /dev/null
+++ b/.rules/plan/09-15-reject-image-document.md
@@ -0,0 +1,109 @@
+# Phase 09 — Reject image and document content blocks
+
+**Estimated time:** ~15 minutes
+**Touches:**
+`lib/dispatch/adapter/minimax/request_builder/messages.rb` (most likely),
+or wherever interface `Message` content blocks are converted to the wire
+format.
+
+## Goal
+
+MiniMax's compatibility docs explicitly state:
+
+- `type="image"` is NOT supported.
+- `type="document"` is NOT supported.
+
+Currently the `Messages` builder probably forwards image / document
+blocks transparently, relying on Anthropic's behavior. We must reject
+them at request-build time with a clear `ArgumentError`. Sending a
+malformed request and getting a server-side 400 is worse UX than failing
+locally with a useful message.
+
+## Steps
+
+### 1. Identify the message-conversion file
+
+Read `lib/dispatch/adapter/minimax/request_builder/messages.rb`. It will
+have a method (likely `Messages.build` or `convert_message`) that walks
+the interface message's `content` array and converts each block to the
+wire format. Look for the `case block.class` (or `case block.type`)
+dispatch.
+
+### 2. Add explicit rejection branches
+
+For ImageBlock-type and DocumentBlock-type interface blocks (or
+generically: any content block whose wire `type` would be `"image"` or
+`"document"`), raise `ArgumentError` with a descriptive message.
+
+Example (adjust to fit the actual class names in
+`dispatch-adapter-interface`):
+
+```ruby
+case block
+when Dispatch::Adapter::TextBlock
+ { type: "text", text: block.text }
+when Dispatch::Adapter::ImageBlock
+ raise ArgumentError,
+ "MiniMax does not support image content blocks " \
+ "(see https://platform.minimax.io/docs/api-reference/text-anthropic-api)."
+when Dispatch::Adapter::DocumentBlock
+ raise ArgumentError,
+ "MiniMax does not support document content blocks " \
+ "(see https://platform.minimax.io/docs/api-reference/text-anthropic-api)."
+when Dispatch::Adapter::ThinkingBlock
+ # ... existing handling ...
+when Dispatch::Adapter::ToolUseBlock
+ # ... existing handling ...
+when Dispatch::Adapter::ToolResultBlock
+ # ... existing handling ...
+else
+ raise ArgumentError, "Unsupported content block: #{block.class}"
+end
+```
+
+If `dispatch-adapter-interface` does not actually export
+`ImageBlock` / `DocumentBlock` constants (verify by reading the gem
+source under
+`reference/dispatch-adapter-minimax/Gemfile.lock` → `dispatch-adapter-interface`,
+or checking the gemspec dependency), use a different detection. For
+example, if interface only exposes a generic `ContentBlock` with a
+`type` accessor, branch on `block.type == "image"` /
+`block.type == "document"` instead.
+
+### 3. Mirror the rejection in tool-result content if needed
+
+If a `ToolResultBlock` can carry image/document content as a sub-block
+(some Anthropic shapes allow this), the inner-content walker also needs
+the same rejection. Check
+`lib/dispatch/adapter/minimax/request_builder/messages.rb` for any
+nested content walking and apply the same guard.
+
+If you find nothing nested, do not invent code — just leave it.
+
+### 4. Confirm no upstream supplier of image blocks
+
+Run `grep -rn 'ImageBlock\|DocumentBlock' lib/`. The only matches should
+be the rejection branches you just added. If lib code elsewhere
+constructs image/document blocks (it shouldn't — they are caller input),
+that is a bug to investigate.
+
+## Acceptance criteria
+
+- Building a request with a message whose content includes an ImageBlock
+ raises `ArgumentError` whose message contains the substring
+ `"MiniMax does not support image"`.
+- Same for DocumentBlock with `"MiniMax does not support document"`.
+- Building a request with only TextBlock / ThinkingBlock / ToolUseBlock /
+ ToolResultBlock content succeeds as before.
+- `bundle exec rubocop --autocorrect-all` exits 0.
+
+## Verification
+
+Run `run_tests` with `project_path=reference/dispatch-adapter-minimax`.
+Rubocop must be clean. RSpec failures referring to image/document
+fixtures are unlikely (the original specs probably only used text and
+tools), but if any exist they are addressed in phase 13. Any failure NOT
+explainable that way must be fixed before calling `ask_for_next_plan`.
+
+NOTE: Test coverage for the new rejection branches is added in phase 13
+(retarget request_builder spec). Do NOT add specs here.