fix(embed): add comprehensive diagnostic tracing for Qdrant

- client.rs: detect document mismatch in embed_batch, warn on empty vectors
- qdrant.rs: reject empty vectors with error logging
- service.rs: add debug/info tracing to embed_issue, embed_repo, embed_issues, embed_skill
This commit is contained in:
ZhenYi 2026-04-29 15:35:18 +08:00
parent 867f216a1f
commit 395832118e

View File

@ -58,13 +58,24 @@ impl EmbedClient {
.await
.map_err(|e| crate::AgentError::OpenAi(format!("embedding batch failed: {}", e)))?;
tracing::debug!(input_count = texts.len(), returned_count = embeddings.len(), "embed_batch: API returned");
let mut result = vec![Vec::new(); texts.len()];
for embedding in embeddings {
// Find the original index by matching the document text
if let Some(idx) = texts.iter().position(|t| t == &embedding.document) {
result[idx] = embedding.vec.iter().map(|v| *v as f32).collect();
} else {
tracing::warn!(doc = %embedding.document, "embed_batch: document mismatch — text not found in input list");
}
}
// Check for empty results
let empty_count = result.iter().filter(|v| v.is_empty()).count();
if empty_count > 0 {
tracing::warn!(empty_count = empty_count, total = texts.len(), "embed_batch: some embeddings returned empty vectors");
}
Ok(result)
}