fix: start SSH rate limiter cleanup and fix ToolContext reset per tool call
- Start SSH rate limiter cleanup task that was missing (prevent memory leak) - Create single ToolContext outside tool execution loop so max_tool_calls and max_depth guards actually fire across batch tool calls (was creating fresh context per call, bypassing all limits)
This commit is contained in:
parent
09645d8641
commit
0a272ed63a
@ -419,8 +419,7 @@ impl ChatService {
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut tool_messages = Vec::new();
|
let mut tool_messages = Vec::new();
|
||||||
for call in &calls {
|
let mut ctx = crate::tool::ToolContext::new(
|
||||||
let ctx = &mut crate::tool::ToolContext::new(
|
|
||||||
request.db.clone(),
|
request.db.clone(),
|
||||||
request.cache.clone(),
|
request.cache.clone(),
|
||||||
request.config.clone(),
|
request.config.clone(),
|
||||||
@ -430,9 +429,9 @@ impl ChatService {
|
|||||||
if let Some(ref registry) = self.tool_registry {
|
if let Some(ref registry) = self.tool_registry {
|
||||||
ctx.registry_mut().merge(registry.clone());
|
ctx.registry_mut().merge(registry.clone());
|
||||||
}
|
}
|
||||||
|
for call in &calls {
|
||||||
let executor = crate::tool::ToolExecutor::new();
|
let executor = crate::tool::ToolExecutor::new();
|
||||||
let results = match executor.execute_batch(vec![call.clone()], ctx).await {
|
let results = match executor.execute_batch(vec![call.clone()], &mut ctx).await {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let err_text = format!("[Tool call failed: {}]", e);
|
let err_text = format!("[Tool call failed: {}]", e);
|
||||||
|
|||||||
@ -138,6 +138,8 @@ impl SSHHandle {
|
|||||||
|
|
||||||
// Start the rate limiter cleanup background task so the HashMap
|
// Start the rate limiter cleanup background task so the HashMap
|
||||||
// doesn't grow unbounded over time.
|
// doesn't grow unbounded over time.
|
||||||
|
let _cleanup = server.rate_limiter.clone().start_cleanup();
|
||||||
|
|
||||||
let ssh_port = self.app.ssh_port()?;
|
let ssh_port = self.app.ssh_port()?;
|
||||||
let bind_addr = format!("0.0.0.0:{}", ssh_port);
|
let bind_addr = format!("0.0.0.0:{}", ssh_port);
|
||||||
let public_host = self.app.ssh_domain()?;
|
let public_host = self.app.ssh_domain()?;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user