style(agent): apply rustfmt formatting to loop_.rs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0c46b56555
commit
cb7df7c87f
1 changed files with 17 additions and 7 deletions
|
|
@ -466,7 +466,8 @@ fn parse_tool_calls(response: &str) -> (String, Vec<ParsedToolCall>) {
|
||||||
// ```tool_call ... </tool_call> instead of structured API calls or XML tags.
|
// ```tool_call ... </tool_call> instead of structured API calls or XML tags.
|
||||||
if calls.is_empty() {
|
if calls.is_empty() {
|
||||||
static MD_TOOL_CALL_RE: LazyLock<Regex> = LazyLock::new(|| {
|
static MD_TOOL_CALL_RE: LazyLock<Regex> = LazyLock::new(|| {
|
||||||
Regex::new(r"(?s)```tool[_-]?call\s*\n(.*?)(?:```|</tool[_-]?call>|</toolcall>)").unwrap()
|
Regex::new(r"(?s)```tool[_-]?call\s*\n(.*?)(?:```|</tool[_-]?call>|</toolcall>)")
|
||||||
|
.unwrap()
|
||||||
});
|
});
|
||||||
let mut md_remaining = response;
|
let mut md_remaining = response;
|
||||||
let mut md_text_parts: Vec<String> = Vec::new();
|
let mut md_text_parts: Vec<String> = Vec::new();
|
||||||
|
|
@ -676,14 +677,17 @@ pub(crate) async fn run_tool_call_loop(
|
||||||
let assistant_history_content = if resp.tool_calls.is_empty() {
|
let assistant_history_content = if resp.tool_calls.is_empty() {
|
||||||
response_text.clone()
|
response_text.clone()
|
||||||
} else {
|
} else {
|
||||||
build_native_assistant_history(
|
build_native_assistant_history(&response_text, &resp.tool_calls)
|
||||||
&response_text,
|
|
||||||
&resp.tool_calls,
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let native_calls = resp.tool_calls;
|
let native_calls = resp.tool_calls;
|
||||||
(response_text, parsed_text, calls, assistant_history_content, native_calls)
|
(
|
||||||
|
response_text,
|
||||||
|
parsed_text,
|
||||||
|
calls,
|
||||||
|
assistant_history_content,
|
||||||
|
native_calls,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
observer.record_event(&ObserverEvent::LlmResponse {
|
observer.record_event(&ObserverEvent::LlmResponse {
|
||||||
|
|
@ -714,7 +718,13 @@ pub(crate) async fn run_tool_call_loop(
|
||||||
let response_text = resp;
|
let response_text = resp;
|
||||||
let assistant_history_content = response_text.clone();
|
let assistant_history_content = response_text.clone();
|
||||||
let (parsed_text, calls) = parse_tool_calls(&response_text);
|
let (parsed_text, calls) = parse_tool_calls(&response_text);
|
||||||
(response_text, parsed_text, calls, assistant_history_content, Vec::new())
|
(
|
||||||
|
response_text,
|
||||||
|
parsed_text,
|
||||||
|
calls,
|
||||||
|
assistant_history_content,
|
||||||
|
Vec::new(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
observer.record_event(&ObserverEvent::LlmResponse {
|
observer.record_event(&ObserverEvent::LlmResponse {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue