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 @@ -668,10 +668,27 @@ struct reasoning_cache {
668
668
}
669
669
670
670
for (auto &msg : messages) {
671
+ std::string role = json_value (msg, " role" , std::string ());
672
+ if (role != " assistant" ) {
673
+ continue ;
674
+ }
675
+
671
676
if (!msg.contains (" tool_calls" ) || msg.contains (" reasoning_content" )) {
672
677
continue ;
673
678
}
674
679
680
+ // do not inject if the message contains a non-empty content
681
+ if (msg.contains (" content" )) {
682
+ if (msg.at (" content" ).is_string ()) {
683
+ std::string content = json_value (msg, " content" , std::string ());
684
+ if (!content.empty ()) {
685
+ continue ;
686
+ }
687
+ } else if (!msg.at (" content" ).empty ()) {
688
+ continue ;
689
+ }
690
+ }
691
+
675
692
// inject cached reasoning to tool call messages to support models that require it (gpt-oss)
676
693
const json & tool_calls = msg.at (" tool_calls" );
677
694
if (tool_calls.is_array () && !tool_calls.empty ()) {
You can’t perform that action at this time.
0 commit comments