fixed bug in Bedrock translation code and dramatically improved tracing for outbound LLM traffic (#601)

* dramatically improve LLM traces and fixed bug with Bedrock translation from claude code

* addressing comments

---------

Co-authored-by: Salman Paracha <salmanparacha@MacBook-Pro-288.local>
This commit is contained in:
Salman Paracha 2025-10-24 14:07:05 -07:00 committed by GitHub
parent 0ee0912a73
commit 566e7b9c09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 149 additions and 61 deletions

View file

@ -97,21 +97,24 @@ impl TryFrom<AnthropicMessagesRequest> for ConverseRequest {
});
// Convert tools and tool choice to ToolConfiguration
let tool_config = if req.tools.is_some() || req.tool_choice.is_some() {
let tools = req.tools.map(|anthropic_tools| {
anthropic_tools
.into_iter()
.map(|tool| BedrockTool::ToolSpec {
tool_spec: ToolSpecDefinition {
name: tool.name,
description: tool.description,
input_schema: ToolInputSchema {
json: tool.input_schema,
},
// Only include toolConfig if we have actual tools (Bedrock requires at least 1 tool)
let tool_config = req.tools.and_then(|anthropic_tools| {
if anthropic_tools.is_empty() {
return None;
}
let tools = anthropic_tools
.into_iter()
.map(|tool| BedrockTool::ToolSpec {
tool_spec: ToolSpecDefinition {
name: tool.name,
description: tool.description,
input_schema: ToolInputSchema {
json: tool.input_schema,
},
})
.collect()
});
},
})
.collect();
let tool_choice = req.tool_choice.map(|choice| {
match choice.kind {
@ -136,10 +139,11 @@ impl TryFrom<AnthropicMessagesRequest> for ConverseRequest {
}
});
Some(ToolConfiguration { tools, tool_choice })
} else {
None
};
Some(ToolConfiguration {
tools: Some(tools),
tool_choice,
})
});
Ok(ConverseRequest {
model_id: req.model,