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
+8 -3
View File
@@ -324,7 +324,12 @@ impl LlmClient {
name,
arguments_delta,
} => {
while self.tool_calls.len() <= *index {
// Cap the index to prevent memory exhaustion from
// maliciously large indices.
const MAX_TOOL_CALLS: usize = 64;
let index = usize::min(*index, MAX_TOOL_CALLS.saturating_sub(1));
while self.tool_calls.len() <= index {
self.tool_calls.push(zesdex_domain::core::ToolCall {
id: String::new(),
type_: "function".to_string(),
@@ -334,8 +339,8 @@ impl LlmClient {
},
});
}
let tc = &mut self.tool_calls[*index];
let tc = &mut self.tool_calls[index];
if let Some(ref id_val) = id {
tc.id = id_val.clone();