File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -672,10 +672,27 @@ struct reasoning_cache {
672672 }
673673
674674 for (auto &msg : messages) {
675+ std::string role = json_value (msg, " role" , std::string ());
676+ if (role != " assistant" ) {
677+ continue ;
678+ }
679+
675680 if (!msg.contains (" tool_calls" ) || msg.contains (" reasoning_content" )) {
676681 continue ;
677682 }
678683
684+ // do not inject if the message contains a non-empty content
685+ if (msg.contains (" content" )) {
686+ if (msg.at (" content" ).is_string ()) {
687+ std::string content = json_value (msg, " content" , std::string ());
688+ if (!content.empty ()) {
689+ continue ;
690+ }
691+ } else if (!msg.at (" content" ).empty ()) {
692+ continue ;
693+ }
694+ }
695+
679696 // inject cached reasoning to tool call messages to support models that require it (gpt-oss)
680697 const json & tool_calls = msg.at (" tool_calls" );
681698 if (tool_calls.is_array () && !tool_calls.empty ()) {
You can’t perform that action at this time.
0 commit comments