fix: parse flat content arrays in Responses API input

When input is [{type: 'input_image', ...}, {type: 'input_text', text: '...'}],
the code was looking for items with role: 'user' which don't exist in flat
content arrays. Now extracts text from input_text items directly first,
falling back to role-based messages only if no flat text found.

Also adds debug header dump for MITM request forwarding.
This commit is contained in:
Nikketryhard
2026-02-15 18:10:03 -06:00
parent 1a6bfa5b53
commit 371c57bab0
2 changed files with 51 additions and 25 deletions

View File

@@ -633,6 +633,16 @@ async fn handle_http_over_tls(
};
// Forward the request — if write fails, reconnect and retry once
// DEBUG: dump headers and total size
if req_path.contains("streamGenerateContent") {
let hdr_end = find_headers_end(&request_buf).unwrap_or(request_buf.len());
let hdr_str = String::from_utf8_lossy(&request_buf[..hdr_end.min(request_buf.len())]);
info!(
total_buf_len = request_buf.len(),
body_len = request_buf.len() - hdr_end,
"MITM: sending request to upstream\n{hdr_str}"
);
}
if let Err(e) = conn.write_all(&request_buf).await {
debug!(domain, error = %e, "MITM: upstream write failed, reconnecting");
let c = connect_upstream(domain, &upstream_config).await?;