Skip to content

Commit 6ca405b

Browse files
committed
Remove excess debug logs.
1 parent ab2b654 commit 6ca405b

File tree

1 file changed

+5
-52
lines changed

1 file changed

+5
-52
lines changed

shinkai-bin/shinkai-node/src/llm_provider/providers/openai_responses.rs

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,10 @@ pub async fn call_api(
124124
"llm_payload",
125125
&payload_log,
126126
) {
127-
eprintln!("failed to add payload trace: {:?}", e);
127+
// ignore tracing failures
128128
}
129129
}
130130

131-
eprintln!("Call API Body: {}", serde_json::to_string_pretty(&payload).unwrap());
132131

133132
if is_stream {
134133
handle_streaming_response_responses(
@@ -198,8 +197,6 @@ async fn handle_non_streaming_response_responses(
198197

199198
let response_json: serde_json::Value = res.json().await?;
200199

201-
eprintln!("Response JSON: {}", serde_json::to_string_pretty(&response_json).unwrap());
202-
203200
// Only extract from output.content[].text where type="output_text" - no fallbacks
204201
// 1) Text content
205202
let mut response_text = String::new();
@@ -408,9 +405,6 @@ async fn handle_streaming_response_responses(
408405
}
409406

410407
if let Some(ev) = event_type {
411-
// Debug: log all events to understand what we're receiving
412-
eprintln!("DEBUG Streaming event: '{}' with data: '{}'", ev, data_buf.chars().take(200).collect::<String>());
413-
414408
// handle event
415409
match ev.as_str() {
416410
// Text deltas
@@ -550,7 +544,6 @@ async fn handle_streaming_response_responses(
550544
.or_else(|| v.get("id").and_then(|s| s.as_str()).map(|s| s.to_string())) {
551545
let name = v.get("name").and_then(|s| s.as_str()).map(|s| s.to_string())
552546
.or_else(|| v.get("function").and_then(|f| f.get("name")).and_then(|s| s.as_str()).map(|s| s.to_string()));
553-
eprintln!("DEBUG function_call.created: id={}, name={:?}", id, name);
554547
tools_map.entry(id).or_insert(ToolAccum { name, arguments: String::new(), call_type: Some("function".to_string()) });
555548
}
556549
}
@@ -567,10 +560,7 @@ async fn handle_streaming_response_responses(
567560
}
568561
// delta may be in {"delta":{"arguments":"..."}}
569562
if let Some(delta) = v.get("delta") {
570-
if let Some(args) = delta.get("arguments").and_then(|a| a.as_str()) {
571-
eprintln!("DEBUG function_call.delta: id={}, args_delta='{}'", id, args);
572-
entry.arguments.push_str(args);
573-
}
563+
if let Some(args) = delta.get("arguments").and_then(|a| a.as_str()) { entry.arguments.push_str(args); }
574564
}
575565
}
576566
}
@@ -583,12 +573,7 @@ async fn handle_streaming_response_responses(
583573
.or_else(|| v.get("id").and_then(|s| s.as_str())) {
584574
let entry = tools_map.entry(id.to_string()).or_insert(ToolAccum { name: None, arguments: String::new(), call_type: Some("function".to_string()) });
585575
// OpenAI Responses API puts the delta directly in the "delta" field
586-
if let Some(delta) = v.get("delta").and_then(|d| d.as_str()) {
587-
eprintln!("DEBUG function_call_arguments.delta: id={}, delta='{}'", id, delta);
588-
entry.arguments.push_str(delta);
589-
} else {
590-
eprintln!("DEBUG function_call_arguments.delta: id={}, no delta found in data: '{}'", id, data_buf.chars().take(200).collect::<String>());
591-
}
576+
if let Some(delta) = v.get("delta").and_then(|d| d.as_str()) { entry.arguments.push_str(delta); }
592577
}
593578
}
594579
}
@@ -598,7 +583,6 @@ async fn handle_streaming_response_responses(
598583
if let Some(id) = v.get("item_id").and_then(|s| s.as_str())
599584
.or_else(|| v.get("call_id").and_then(|s| s.as_str()))
600585
.or_else(|| v.get("id").and_then(|s| s.as_str())) {
601-
eprintln!("DEBUG function_call_arguments.done: id={}, tools_map contains: {:?}", id, tools_map.get(id));
602586

603587
// Get the complete arguments from the event (fallback to accumulated)
604588
let final_arguments = v.get("arguments").and_then(|a| a.as_str())
@@ -607,7 +591,6 @@ async fn handle_streaming_response_responses(
607591
.unwrap_or_default();
608592

609593
if let Some(acc) = tools_map.remove(id) {
610-
eprintln!("DEBUG function_call_arguments.done: removed from tools_map, name={:?}, final_args='{}'", acc.name, final_arguments);
611594
if let Some(name) = acc.name {
612595
let args_map = serde_json::from_str::<serde_json::Value>(&final_arguments)
613596
.ok()
@@ -622,19 +605,13 @@ async fn handle_streaming_response_responses(
622605
id: Some(id.to_string()),
623606
call_type: acc.call_type.or(Some("function".to_string())),
624607
});
625-
eprintln!("DEBUG function_call_arguments.done: added to function_calls, total count now: {}", function_calls.len());
626-
627608
// Send WebSocket update for this function call
628609
if let Some(ref inbox) = inbox_name {
629610
if let Some(last) = function_calls.last() {
630611
let _ = super::shared::shared_model_logic::send_tool_ws_update(&ws_manager_trait, Some(inbox.clone()), last).await;
631612
}
632613
}
633-
} else {
634-
eprintln!("DEBUG function_call_arguments.done: WARNING - acc.name is None!");
635614
}
636-
} else {
637-
eprintln!("DEBUG function_call_arguments.done: WARNING - id '{}' not found in tools_map!", id);
638615
}
639616
}
640617
}
@@ -643,9 +620,7 @@ async fn handle_streaming_response_responses(
643620
if let Ok(v) = serde_json::from_str::<serde_json::Value>(&data_buf) {
644621
if let Some(id) = v.get("call_id").and_then(|s| s.as_str())
645622
.or_else(|| v.get("id").and_then(|s| s.as_str())) {
646-
eprintln!("DEBUG function_call.done: id={}, tools_map contains: {:?}", id, tools_map.get(id));
647623
if let Some(acc) = tools_map.remove(id) {
648-
eprintln!("DEBUG function_call.done: removed from tools_map, name={:?}, args='{}'", acc.name, acc.arguments);
649624
if let Some(name) = acc.name {
650625
let args_map = serde_json::from_str::<serde_json::Value>(&acc.arguments)
651626
.ok()
@@ -660,12 +635,7 @@ async fn handle_streaming_response_responses(
660635
id: Some(id.to_string()),
661636
call_type: acc.call_type.or(Some("function".to_string())),
662637
});
663-
eprintln!("DEBUG function_call.done: added to function_calls, total count now: {}", function_calls.len());
664-
} else {
665-
eprintln!("DEBUG function_call.done: WARNING - acc.name is None!");
666638
}
667-
} else {
668-
eprintln!("DEBUG function_call.done: WARNING - id '{}' not found in tools_map!", id);
669639
}
670640
if let Some(ref inbox) = inbox_name {
671641
if let Some(last) = function_calls.last() {
@@ -679,10 +649,8 @@ async fn handle_streaming_response_responses(
679649
"response.completed" => {
680650
// finalize any remaining tool calls
681651
let ids: Vec<String> = tools_map.keys().cloned().collect();
682-
eprintln!("DEBUG response.completed: finalizing {} remaining tool calls", ids.len());
683652
for id in ids {
684653
if let Some(acc) = tools_map.remove(&id) {
685-
eprintln!("DEBUG response.completed: finalizing tool call id={}, name={:?}, args='{}'", id, acc.name, acc.arguments);
686654
if let Some(name) = acc.name {
687655
let args_map = serde_json::from_str::<serde_json::Value>(&acc.arguments)
688656
.ok()
@@ -697,7 +665,6 @@ async fn handle_streaming_response_responses(
697665
id: Some(id.to_string()),
698666
call_type: acc.call_type.or(Some("function".to_string())),
699667
});
700-
eprintln!("DEBUG response.completed: added to function_calls, total count now: {}", function_calls.len());
701668
}
702669
}
703670
}
@@ -739,7 +706,6 @@ async fn handle_streaming_response_responses(
739706
let name = item.get("name").and_then(|n| n.as_str()).map(|s| s.to_string())
740707
.or_else(|| item.get("function_name").and_then(|n| n.as_str()).map(|s| s.to_string()))
741708
.or_else(|| item.get("function").and_then(|f| f.get("name")).and_then(|n| n.as_str()).map(|s| s.to_string()));
742-
eprintln!("DEBUG output_item.added (function_call): id={}, name={:?}, full_item={}", id, name, serde_json::to_string(&item).unwrap_or_default());
743709
tools_map.entry(id.to_string()).or_insert(ToolAccum {
744710
name,
745711
arguments: String::new(),
@@ -760,14 +726,11 @@ async fn handle_streaming_response_responses(
760726
let name = item.get("name").and_then(|n| n.as_str()).map(|s| s.to_string())
761727
.or_else(|| item.get("function_name").and_then(|n| n.as_str()).map(|s| s.to_string()))
762728
.or_else(|| item.get("function").and_then(|f| f.get("name")).and_then(|n| n.as_str()).map(|s| s.to_string()));
763-
eprintln!("DEBUG output_item.done (function_call): id={}, name={:?}, full_item={}", id, name, serde_json::to_string(&item).unwrap_or_default());
764-
765729
// Update the tools_map entry with the function name if we found it
766730
if let Some(name) = name {
767731
if let Some(entry) = tools_map.get_mut(id) {
768732
if entry.name.is_none() {
769733
entry.name = Some(name);
770-
eprintln!("DEBUG output_item.done: updated function name for id {}", id);
771734
}
772735
}
773736
}
@@ -776,10 +739,7 @@ async fn handle_streaming_response_responses(
776739
}
777740
}
778741
}
779-
_ => {
780-
// Log unmatched events to see what we're missing
781-
eprintln!("DEBUG Unmatched streaming event: '{}' with data: '{}'", ev, data_buf.chars().take(100).collect::<String>());
782-
}
742+
_ => {}
783743
}
784744
}
785745
} else {
@@ -788,14 +748,7 @@ async fn handle_streaming_response_responses(
788748
}
789749
}
790750

791-
// Debug: log final accumulated data
792-
eprintln!("DEBUG Final streaming result - response_text: '{}', reasoning_text: '{}', function_calls count: {}",
793-
response_text.chars().take(100).collect::<String>(),
794-
reasoning_text.chars().take(100).collect::<String>(),
795-
function_calls.len());
796-
if !function_calls.is_empty() {
797-
eprintln!("DEBUG Function calls: {:?}", function_calls);
798-
}
751+
// End of stream
799752

800753
Ok(LLMInferenceResponse::new(
801754
response_text,

0 commit comments

Comments
 (0)