@@ -101,20 +101,24 @@ absl::Status OpenAIResponsesHandler::parseInput(std::optional<std::string> allow
101101 // Determine item type (if present)
102102 auto itemTypeIt = itemObj.FindMember (" type" );
103103 const std::string itemType = (itemTypeIt != itemObj.MemberEnd () && itemTypeIt->value .IsString ())
104- ? itemTypeIt->value .GetString () : " " ;
104+ ? itemTypeIt->value .GetString ()
105+ : " " ;
105106
106107 // Parse reasoning items — extract summary text and buffer for the next assistant message
107108 if (itemType == " reasoning" ) {
108109 auto summaryIt = itemObj.FindMember (" summary" );
109110 if (summaryIt != itemObj.MemberEnd () && summaryIt->value .IsArray ()) {
110111 for (const auto & summaryItem : summaryIt->value .GetArray ()) {
111- if (!summaryItem.IsObject ()) continue ;
112+ if (!summaryItem.IsObject ())
113+ continue ;
112114 auto stTypeIt = summaryItem.GetObject ().FindMember (" type" );
113- if (stTypeIt == summaryItem.GetObject ().MemberEnd () || !stTypeIt->value .IsString ()) continue ;
115+ if (stTypeIt == summaryItem.GetObject ().MemberEnd () || !stTypeIt->value .IsString ())
116+ continue ;
114117 if (std::string (stTypeIt->value .GetString ()) == " summary_text" ) {
115118 auto textIt = summaryItem.GetObject ().FindMember (" text" );
116119 if (textIt != summaryItem.GetObject ().MemberEnd () && textIt->value .IsString ()) {
117- if (!pendingReasoning.empty ()) pendingReasoning += " \n " ;
120+ if (!pendingReasoning.empty ())
121+ pendingReasoning += " \n " ;
118122 pendingReasoning += textIt->value .GetString ();
119123 }
120124 }
@@ -147,7 +151,8 @@ absl::Status OpenAIResponsesHandler::parseInput(std::optional<std::string> allow
147151 request.chatHistory .last ()[" tool_call_id" ] = callIdIt->value .GetString ();
148152 }
149153 const std::string outputContent = (outputIt != itemObj.MemberEnd () && outputIt->value .IsString ())
150- ? outputIt->value .GetString () : " " ;
154+ ? outputIt->value .GetString ()
155+ : " " ;
151156 request.chatHistory .last ()[" content" ] = outputContent;
152157 continue ;
153158 }
@@ -330,17 +335,20 @@ absl::Status OpenAIResponsesHandler::parseResponsesPart(std::optional<uint32_t>
330335 Value tcObj (kObjectType );
331336 auto idIt = fcObj.FindMember (" id" );
332337 const std::string tcId = (idIt != fcObj.MemberEnd () && idIt->value .IsString ())
333- ? idIt->value .GetString () : " " ;
338+ ? idIt->value .GetString ()
339+ : " " ;
334340 tcObj.AddMember (" id" , Value (tcId.c_str (), alloc), alloc);
335341 tcObj.AddMember (" type" , Value (" function" , alloc), alloc);
336342 Value funcObj (kObjectType );
337343 auto nameIt = fcObj.FindMember (" name" );
338344 const std::string funcName = (nameIt != fcObj.MemberEnd () && nameIt->value .IsString ())
339- ? nameIt->value .GetString () : " " ;
345+ ? nameIt->value .GetString ()
346+ : " " ;
340347 funcObj.AddMember (" name" , Value (funcName.c_str (), alloc), alloc);
341348 auto argsIt = fcObj.FindMember (" arguments" );
342349 const std::string args = (argsIt != fcObj.MemberEnd () && argsIt->value .IsString ())
343- ? argsIt->value .GetString () : " " ;
350+ ? argsIt->value .GetString ()
351+ : " " ;
344352 funcObj.AddMember (" arguments" , Value (args.c_str (), alloc), alloc);
345353 tcObj.AddMember (" function" , funcObj, alloc);
346354 toolCallsArray.PushBack (tcObj, alloc);
@@ -357,9 +365,11 @@ absl::Status OpenAIResponsesHandler::parseResponsesPart(std::optional<uint32_t>
357365 }
358366 if (contentVal.IsArray ()) {
359367 for (auto & ci : contentVal.GetArray ()) {
360- if (!ci.IsObject ()) continue ;
368+ if (!ci.IsObject ())
369+ continue ;
361370 auto ctTypeIt = ci.GetObject ().FindMember (" type" );
362- if (ctTypeIt == ci.GetObject ().MemberEnd () || !ctTypeIt->value .IsString ()) continue ;
371+ if (ctTypeIt == ci.GetObject ().MemberEnd () || !ctTypeIt->value .IsString ())
372+ continue ;
363373 const std::string ctType = ctTypeIt->value .GetString ();
364374 if (ctType == " input_text" || ctType == " output_text" ) {
365375 auto textIt = ci.GetObject ().FindMember (" text" );
@@ -374,25 +384,30 @@ absl::Status OpenAIResponsesHandler::parseResponsesPart(std::optional<uint32_t>
374384
375385 for (rapidjson::SizeType i = 0 ; i < inputArrIt->value .GetArray ().Size (); ++i) {
376386 const auto & item = inputArrIt->value .GetArray ()[i];
377- if (!item.IsObject ()) continue ;
387+ if (!item.IsObject ())
388+ continue ;
378389 auto itemObj = item.GetObject ();
379390
380391 auto itemTypeIt = itemObj.FindMember (" type" );
381392 const std::string itemType = (itemTypeIt != itemObj.MemberEnd () && itemTypeIt->value .IsString ())
382- ? itemTypeIt->value .GetString () : " " ;
393+ ? itemTypeIt->value .GetString ()
394+ : " " ;
383395
384396 // Parse reasoning items — extract summary text and buffer for the next assistant message
385397 if (itemType == " reasoning" ) {
386398 auto summaryIt = itemObj.FindMember (" summary" );
387399 if (summaryIt != itemObj.MemberEnd () && summaryIt->value .IsArray ()) {
388400 for (const auto & summaryItem : summaryIt->value .GetArray ()) {
389- if (!summaryItem.IsObject ()) continue ;
401+ if (!summaryItem.IsObject ())
402+ continue ;
390403 auto stTypeIt = summaryItem.GetObject ().FindMember (" type" );
391- if (stTypeIt == summaryItem.GetObject ().MemberEnd () || !stTypeIt->value .IsString ()) continue ;
404+ if (stTypeIt == summaryItem.GetObject ().MemberEnd () || !stTypeIt->value .IsString ())
405+ continue ;
392406 if (std::string (stTypeIt->value .GetString ()) == " summary_text" ) {
393407 auto textIt = summaryItem.GetObject ().FindMember (" text" );
394408 if (textIt != summaryItem.GetObject ().MemberEnd () && textIt->value .IsString ()) {
395- if (!pendingReasoningJson.empty ()) pendingReasoningJson += " \n " ;
409+ if (!pendingReasoningJson.empty ())
410+ pendingReasoningJson += " \n " ;
396411 pendingReasoningJson += textIt->value .GetString ();
397412 }
398413 }
@@ -418,7 +433,8 @@ absl::Status OpenAIResponsesHandler::parseResponsesPart(std::optional<uint32_t>
418433 }
419434 auto outputIt = itemObj.FindMember (" output" );
420435 const std::string outputContent = (outputIt != itemObj.MemberEnd () && outputIt->value .IsString ())
421- ? outputIt->value .GetString () : " " ;
436+ ? outputIt->value .GetString ()
437+ : " " ;
422438 msgObj.AddMember (" content" , Value (outputContent.c_str (), alloc), alloc);
423439 messagesArray.PushBack (msgObj, alloc);
424440 continue ;
@@ -475,7 +491,8 @@ absl::Status OpenAIResponsesHandler::parseResponsesPart(std::optional<uint32_t>
475491 if (toolsIt != doc.MemberEnd () && !toolsIt->value .IsNull () && toolsIt->value .IsArray ()) {
476492 Value toolsArray (kArrayType );
477493 for (const auto & tool : toolsIt->value .GetArray ()) {
478- if (!tool.IsObject ()) continue ;
494+ if (!tool.IsObject ())
495+ continue ;
479496 auto toolObj = tool.GetObject ();
480497 // Check if this tool already has a nested "function" key (chat/completions format)
481498 if (toolObj.FindMember (" function" ) != toolObj.MemberEnd ()) {
@@ -489,9 +506,11 @@ absl::Status OpenAIResponsesHandler::parseResponsesPart(std::optional<uint32_t>
489506 Value funcObj (kObjectType );
490507 // Copy all fields except "type" and "response" into the nested function object
491508 for (auto it2 = toolObj.MemberBegin (); it2 != toolObj.MemberEnd (); ++it2) {
492- if (!it2->name .IsString ()) continue ;
509+ if (!it2->name .IsString ())
510+ continue ;
493511 const std::string fieldName = it2->name .GetString ();
494- if (fieldName == " type" || fieldName == " response" ) continue ;
512+ if (fieldName == " type" || fieldName == " response" )
513+ continue ;
495514 Value keyCopy (it2->name , alloc);
496515 Value valCopy (it2->value , alloc);
497516 funcObj.AddMember (keyCopy, valCopy, alloc);
0 commit comments