feat(agent): implement agent execution engine and turn handling with background processing

This commit is contained in:
asepharyana
2026-07-20 16:29:39 +07:00
parent 2e8a4f2443
commit efcd191f96
15 changed files with 452 additions and 247 deletions
+6 -2
View File
@@ -333,8 +333,9 @@ impl SseParser {
if let Some(tool_calls) =
d.get("tool_calls").and_then(|tc| tc.as_array())
{
const MAX_TOOL_CALLS: usize = 64;
for tc in tool_calls {
let index =
let raw_index =
tc.get("index").and_then(Value::as_u64).unwrap_or_else(
|| {
tracing::warn!(
@@ -344,7 +345,10 @@ impl SseParser {
0
},
);
let index = usize::try_from(index).unwrap_or(0);
// Clamp index to prevent out-of-bounds / memory exhaustion
let index = usize::try_from(raw_index)
.unwrap_or(0)
.min(MAX_TOOL_CALLS.saturating_sub(1));
let id = tc
.get("id")
.and_then(|i| i.as_str())