@@ -17,6 +17,70 @@ fn test_build_response_request_includes_stream_for_http() {
1717 assert_eq ! ( request[ "store" ] , serde_json:: json!( false ) ) ;
1818}
1919
20+ #[ test]
21+ fn test_chatgpt_payload_includes_native_image_generation_for_non_codex_models ( ) {
22+ // Regression for issue #115: ChatGPT mode adds a native `image_generation`
23+ // tool. Non-codex models (gpt-5.x, gpt-4o, …) accept it and benefit.
24+ let request = OpenAIProvider :: build_response_request (
25+ "gpt-5.5" ,
26+ "system" . to_string ( ) ,
27+ & [ ] ,
28+ & [ ] ,
29+ true ,
30+ Some ( DEFAULT_MAX_OUTPUT_TOKENS ) ,
31+ None ,
32+ None ,
33+ None ,
34+ None ,
35+ None ,
36+ ) ;
37+
38+ assert ! (
39+ request[ "tools" ]
40+ . as_array( )
41+ . expect( "tools array" )
42+ . iter( )
43+ . any( |tool| tool[ "type" ] == "image_generation" ) ,
44+ "non-codex models should still receive image_generation in ChatGPT mode"
45+ ) ;
46+ }
47+
48+ #[ test]
49+ fn test_chatgpt_payload_excludes_native_image_generation_for_codex_models ( ) {
50+ // Regression for issue #115: codex-family models reject the native
51+ // image_generation tool with a 400 from the OpenAI Responses API. Suppress
52+ // it for any model id whose normalized form contains "codex", including
53+ // the `[1m]` long-context suffix variant.
54+ for model in [
55+ "gpt-5.3-codex" ,
56+ "gpt-5.3-codex-spark" ,
57+ "gpt-5.3-codex-spark[1m]" ,
58+ ] {
59+ let request = OpenAIProvider :: build_response_request (
60+ model,
61+ "system" . to_string ( ) ,
62+ & [ ] ,
63+ & [ ] ,
64+ true ,
65+ Some ( DEFAULT_MAX_OUTPUT_TOKENS ) ,
66+ None ,
67+ None ,
68+ None ,
69+ None ,
70+ None ,
71+ ) ;
72+
73+ assert ! (
74+ request[ "tools" ]
75+ . as_array( )
76+ . expect( "tools array" )
77+ . iter( )
78+ . all( |tool| tool[ "type" ] != "image_generation" ) ,
79+ "{model} should not receive the unsupported native image_generation tool"
80+ ) ;
81+ }
82+ }
83+
2084#[ test]
2185fn test_websocket_payload_strips_stream_and_background ( ) {
2286 let mut request = OpenAIProvider :: build_response_request (
0 commit comments