Skip to content

Revert "feat(image): add image generation tool support" - #1087

Merged
CatherineSue merged 1 commit into
mainfrom
revert-1057-tingzhou/add-img-tool-rebase-2
Apr 10, 2026
Merged

CatherineSue merged 1 commit into
mainfrom
revert-1057-tingzhou/add-img-tool-rebase-2

Conversation

@CatherineSue

@CatherineSue CatherineSue commented Apr 10, 2026 •

Copy link
Copy Markdown
Member

Reverts #1057

This PR only included e2e tests for gpt-5.1 models. However, it touched couple of files in grpc routers.

The changes here are not fully covered in e2e tests.

Summary by CodeRabbit

  • Chores
    • Removed image generation tool support from the system, including removal of associated configurations, event handling, and MCP routing logic.
    • Simplified tool output processing by removing response format-based output compaction.

@github-actions github-actions Bot added grpc gRPC client and router changes mcp MCP related changes protocols Protocols crate changes model-gateway Model gateway crate changes openai OpenAI router changes labels Apr 10, 2026
@coderabbitai

coderabbitai Bot commented Apr 10, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 47958518-45fb-4cd0-be75-ce3c6341f793

📥 Commits

Reviewing files that changed from the base of the PR and between 7e7cee2 and 6bc5e9d.

📒 Files selected for processing (20)
  • .gitignore
  • crates/mcp/src/core/config.rs
  • crates/mcp/src/lib.rs
  • crates/mcp/src/transform/mod.rs
  • crates/mcp/src/transform/transformer.rs
  • crates/mcp/src/transform/types.rs
  • crates/protocols/src/event_types.rs
  • crates/protocols/src/responses.rs
  • model_gateway/src/routers/grpc/common/responses/streaming.rs
  • model_gateway/src/routers/grpc/common/responses/utils.rs
  • model_gateway/src/routers/grpc/harmony/builder.rs
  • model_gateway/src/routers/grpc/regular/responses/common.rs
  • model_gateway/src/routers/grpc/regular/responses/non_streaming.rs
  • model_gateway/src/routers/grpc/regular/responses/streaming.rs
  • model_gateway/src/routers/mcp_utils.rs
  • model_gateway/src/routers/mod.rs
  • model_gateway/src/routers/openai/mcp/tool_loop.rs
  • model_gateway/src/routers/openai/responses/streaming.rs
  • model_gateway/src/routers/openai/responses/utils.rs
  • model_gateway/src/routers/tool_output_context.rs

📝 Walkthrough

Walkthrough

This PR removes comprehensive image-generation tool support from the codebase, including enum variants, type definitions, transformer functions, routing logic, event handling, re-exports, and utility functions across MCP, protocols, and model gateway components. JSON value parameter types are standardized to serde_json::Value throughout transformers.

Changes

Cohort / File(s) Summary
Configuration & Type Definitions
.gitignore, crates/mcp/src/core/config.rs, crates/mcp/src/transform/types.rs
Removed BuiltinToolType::ImageGeneration and ResponseFormatConfig::ImageGenerationCall variants; stopped ignoring mcp.local.yaml in version control.
MCP & Transform Exports
crates/mcp/src/lib.rs, crates/mcp/src/transform/mod.rs
Removed public re-exports of extract_image_generation_fallback_text and is_image_generation_error from transform module.
Transform Implementation
crates/mcp/src/transform/transformer.rs
Deleted image-generation transformation path and helper functions; standardized all JSON value parameters to serde_json::Value for type consistency across web search, code interpreter, and file search handlers.
Protocol Event & Response Types
crates/protocols/src/event_types.rs, crates/protocols/src/responses.rs
Removed ImageGenerationCallEvent enum, ItemType::ImageGenerationCall variant, ResponseTool::ImageGeneration, ResponseOutputItem::ImageGenerationCall, and ImageGenerationCallStatus enum.
GRPC Streaming & Routing
model_gateway/src/routers/grpc/common/responses/streaming.rs, model_gateway/src/routers/grpc/common/responses/utils.rs, model_gateway/src/routers/grpc/harmony/builder.rs, model_gateway/src/routers/mcp_utils.rs
Removed image-generation handling from tool-call lifecycle emissions, builtin-tool detection, and routing logic; updated BUILTIN_TOOLS constant and tool-type mappings.
Regular Tool Loop & Output
model_gateway/src/routers/grpc/regular/responses/common.rs, model_gateway/src/routers/grpc/regular/responses/non_streaming.rs, model_gateway/src/routers/grpc/regular/responses/streaming.rs
Changed ToolLoopState::record_call signature to use _success: bool instead of response_format: ResponseFormat; updated call sites in streaming and non-streaming paths.
OpenAI Router MCP & Response Handling
model_gateway/src/routers/openai/mcp/tool_loop.rs, model_gateway/src/routers/openai/responses/streaming.rs, model_gateway/src/routers/openai/responses/utils.rs
Removed image-generation event mapping, ID normalization, and tool restoration logic; refactored execute_streaming_tool_calls signature and removed request-level tool-argument overrides; changed streaming/non-streaming output recording to use raw strings.
Utility & Module Cleanup
model_gateway/src/routers/tool_output_context.rs, model_gateway/src/routers/mod.rs
Removed tool_output_context.rs module and deleted exported compact_tool_output_for_model_context function that previously summarized image-generation tool outputs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • smg#1057 – Directly inverse relationship: this PR removes the image-generation support that PR #1057 originally introduced.
  • smg#730 – Modifies the same OpenAI router MCP tool-loop code (execute_streaming_tool_calls, ToolLoopState) and related re-exports.
  • smg#989 – Touches overlapping MCP transform exports and transformer.rs symbols, particularly mcp_response_item_id and ID normalization logic.

Suggested labels

mcp, model-gateway, protocols, openai, grpc, refactoring, breaking-change

Suggested reviewers

  • key4ng
  • slin1237

Poem

🐰 The image tool is gone, off to greener fields,
Where code and search and files now wield their shields—
No more GENERATING, no more partial frames,
Just transformers stripped clean of image names,
A simpler MCP, leaner routes remain!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revert-1057-tingzhou/add-img-tool-rebase-2

Comment @coderabbitai help to get the list of available commands and usage tips.

@CatherineSue
CatherineSue merged commit d09cb63 into main Apr 10, 2026
1 of 4 checks passed
@CatherineSue
CatherineSue deleted the revert-1057-tingzhou/add-img-tool-rebase-2 branch April 10, 2026 05:27

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request removes image generation tool support across the MCP and protocols crates, deleting associated enum variants, logic, and the tool_output_context utility. Feedback identifies a regression where converting tool outputs to strings via .to_string() introduces unnecessary quotes into conversation histories, which should be corrected to maintain raw text. Additionally, it is recommended to replace the newly introduced boolean success flag with an HTTP status code to properly support circuit breaker functionality when recording tool outcomes.


let model_context_output =
compact_tool_output_for_model_context(&response_format, &tool_output.output);
let output_str = tool_output.output.to_string();

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.

medium

Using to_string() on a serde_json::Value that is a string will include the surrounding double quotes in the resulting String. This is a regression from the previous logic (which used compact_tool_output_for_model_context) and can lead to malformed conversation history being sent back to the model, as tool outputs are expected to be raw text when possible.

Suggested change
let output_str = tool_output.output.to_string();
let output_str = tool_output.output.as_str().map(String::from).unwrap_or_else(|| tool_output.output.to_string());

},
);

let output_str = tool_output.output.to_string();

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.

medium

Similar to the streaming path, using to_string() directly on the tool output value will introduce unnecessary quotes if the output is a plain string, which degrades the quality of the conversation history sent to the model.

Suggested change
let output_str = tool_output.output.to_string();
let output_str = tool_output.output.as_str().map(String::from).unwrap_or_else(|| tool_output.output.to_string());

output_str: String,
response_format: ResponseFormat,
output_item: ResponseOutputItem,
_success: bool,

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.

medium

The _success parameter (boolean) should be replaced with an HTTP status code. According to repository rules, when recording the outcome of a worker request, the record_outcome function must be called with the HTTP status code rather than a boolean. This allows the worker's internal logic to determine if the status code represents a circuit breaker failure.

References
  1. When recording the outcome of a worker request, ensure that the record_outcome function is called with the HTTP status code, not a boolean indicating success or failure. The worker's internal logic will determine if the status code represents a circuit breaker failure based on its configured retryable status codes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

grpc gRPC client and router changes mcp MCP related changes model-gateway Model gateway crate changes openai OpenAI router changes protocols Protocols crate changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant