Skip to content

feat: add Responses API support and OpenAI Chat image rewriting - #13

Merged
Anionex merged 2 commits into
Anionex:mainfrom
zacks3176:feat/responses-protocol-vision
Aug 14, 2026
Merged

feat: add Responses API support and OpenAI Chat image rewriting#13
Anionex merged 2 commits into
Anionex:mainfrom
zacks3176:feat/responses-protocol-vision

Conversation

@zacks3176

@zacks3176 zacks3176 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Problem

The shared Python vision client only supported OpenAI Chat Completions, so a vision model exposed exclusively through the Responses API could not back glance, ground, detect, or the Python proxy. Separately, the proxy did not recognize OpenAI Chat Completions request bodies containing messages[].content[].image_url, so those images could reach a text-only upstream unchanged.

Changes

  • Add VISION_API_PROTOCOL=responses to the shared Python client:
    • sends images as input_image blocks followed by input_text;
    • uses max_output_tokens;
    • optionally sends VISION_REASONING_EFFORT;
    • explicitly sends store: false so image requests are not stored by default;
    • parses output_text from Responses API output messages.
  • Keep Chat Completions as the default, including the browser-compatible/configurable User-Agent already merged in fix: avoid Cloudflare 403 for urllib vision requests #21.
  • Detect and rewrite OpenAI Chat Completions image_url blocks through the existing parallel vision-description pipeline.
  • Use a host-neutral OpenAI Chat channel note that explains how to submit the image again with a more specific question without naming Codex-only tools.
  • Document that VISION_API_PROTOCOL and VISION_REASONING_EFFORT apply to the standalone Python CLIs/proxy; the Pi and OpenCode native extensions continue to use their own settings and /chat/completions.
  • Add protocol, payload, parsing, unsupported-value, ordering, and OpenAI Chat rewrite regression coverage.

Review resolution

All requested changes from the maintainer review are addressed:

  1. Responses requests now set store: false, with a test assertion.
  2. The obsolete hardcoded User-Agent hunk was removed; the branch uses main's VISION_USER_AGENT implementation from fix: avoid Cloudflare 403 for urllib vision requests #21.
  3. Documentation now explicitly limits Responses configuration to the Python client/proxy rather than implying native-extension support.
  4. The OpenAI Chat note is host-neutral and tested not to mention view_image.
  5. AGENT_INSTALL.md, .env.example, the Skill shared-config list, bilingual README text, and CHANGELOG.md are aligned.

Verification

Passed locally after merging the latest main:

  • python3 -m py_compile vision_proxy.py vision_client.py ground.py detect.py bin/glance bin/trace bin/crop
  • python3 tests/test_image_rewrite_shapes.py
  • python3 tests/test_focus_hint.py
  • python3 tests/test_anthropic_rewrite.py
  • python3 tests/smoke_test_proxy.py
  • python3 tests/smoke_test_egress_failover.py
  • python3 tests/test_vision_client.py
  • python3 tests/test_restore_ui_playbook.py
  • node tests/test_extensions.mjs
  • git diff --check

Real Responses API vision request:

  • endpoint: local OpenAI-compatible gateway /v1/responses;
  • model: gpt-5.6-luna;
  • input: generated 32x32 red PNG via input_image;
  • result: A solid red square fills the image.

This is a non-UI protocol/proxy change, so there is no meaningful browser verification path. The substitute verification covers the real Responses API request plus local end-to-end proxy and dialect fixtures.

- vision_client: VISION_API_PROTOCOL=responses sends /responses with
  input_image/input_text parts, max_output_tokens, and reasoning effort,
  enabling vision models like gpt-5.6-luna that only speak the Responses API
- vision_client: send a non-default User-Agent for OpenCode Go compatibility
- vision_proxy: detect and rewrite image_url blocks in OpenAI Chat
  Completions messages (openai_chat format)
- tests: cover responses payload/parsing, UA header, image ordering, and
  openai_chat rewriting
- docs: document VISION_API_PROTOCOL and VISION_REASONING_EFFORT in
  .env.example, READMEs, and AGENT_INSTALL

@Anionex Anionex left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the focused contribution. The feature itself is valuable, and I confirmed that the main implementation works: the required local test suite passes, a real Responses API vision request succeeds, and an end-to-end OpenAI Chat image_url request is rewritten by the proxy and answered successfully by a text-only upstream.

I would like the following items addressed before merge:

  1. Set store: false in Responses requests. The Responses API defaults to storing generated responses. These calls contain the source image and focus prompt, so the client should explicitly disable storage to preserve this project's data-handling expectations. Please add an assertion for this in tests/test_vision_client.py.

  2. Make the custom User-Agent opt-in rather than unconditional. Hardcoding agent-vision-toolkit/0.1 changes every existing Chat Completions request even though the PR otherwise promises that the default path remains unchanged, and this repository keeps UA/header compatibility behavior disabled by default. A VISION_USER_AGENT override would solve the endpoint-specific compatibility case without changing all existing users. Please test both the default and configured cases.

  3. Either propagate the new protocol setting to the native extensions or narrow the documentation. README.md says all entry points share one configuration, but the Pi and OpenCode extensions do not read VISION_API_PROTOCOL and still always call /chat/completions. With a Responses-only endpoint, the Python client/proxy would work while those extensions would fail. Preferably add the same Responses branch to both single-file extensions and their tests; otherwise document that these variables apply only to the Python client/proxy.

  4. Use a host-neutral channel note for openai_chat. It currently reuses the Codex note that tells the model to call view_image. A generic Chat Completions client may not expose that tool, so the note should explain re-querying without naming a host-specific tool.

Please also align the remaining setup text (AGENT_INSTALL.md prerequisite, .env.example capability comment, the shared-config list in the skill) and add the user-visible change to CHANGELOG.md.

Once these are addressed, I think this is worth merging. The body-shape dialect detection and reuse of the existing rewrite pipeline are good choices.

@Anionex

Anionex commented Aug 14, 2026

Copy link
Copy Markdown
Owner

维护者补充审查(对应 #19):本 PR 的 User-Agent slice 目前不完整——固定 agent-vision-toolkit/0.1 不可配置,也没有覆盖已确认的 Cloudflare 1010 场景。该独立 bug 已在 #21 以默认浏览器兼容 UA + VISION_USER_AGENT 覆盖 + HTTP/网络错误脱敏测试处理。后续更新本 PR 时请移除或基于 #21 重放 UA hunk,避免重复实现与冲突;Responses API / OpenAI Chat rewrite 其余范围不受影响。

@Anionex

Anionex commented Aug 14, 2026

Copy link
Copy Markdown
Owner

更新:#21 已于 2026-08-14 合并到 main(merge commit 4fec5c7),Issue #19 已自动关闭。后续更新本 PR 时请基于最新 main 移除原先硬编码 agent-vision-toolkit/0.1 的 User-Agent hunk,保留本 PR 独立的 Responses API / OpenAI Chat rewrite 范围。

@Anionex Anionex changed the title feat: add Responses API protocol support and OpenAI Chat image_url rewriting feat: add Responses API support and OpenAI Chat image rewriting Aug 14, 2026
@Anionex

Anionex commented Aug 14, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 931e1865cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Anionex Anionex left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

All requested changes are addressed on 931e186: store:false is covered, the UA hunk now uses main, native-extension scope is documented accurately, the OpenAI Chat note is host-neutral, supporting docs/changelog are aligned, all CI checks pass, and a real Responses API image request succeeded.

@Anionex
Anionex merged commit 66f1edf into Anionex:main Aug 14, 2026
4 checks passed
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.

2 participants