Hmbown/CodeWhale · error
Runtime has reached the pending dynamic tool call limit
Error message
Runtime has reached the pending dynamic tool call limit ({MAX_PENDING_DYNAMIC_TOOL_CALLS}) What it means
registering a dynamic tool call is capped at MAX_PENDING_DYNAMIC_TOOL_CALLS concurrent pending calls. When the pending map is full, new registrations bail to bound memory and prevent unbounded settlement queues.
Solutions
- Await/settle pending dynamic tool calls before registering more
- Bound concurrency in your caller (semaphore/chunking) below the limit
- Investigate leaked pending entries (undrained receivers) and ensure results are consumed
- Retry registration after pending count drops
Example fix
// before
for req in requests {
runtime.register_dynamic_tool_call(req).await?; // may hit cap
}
// after
let sem = Semaphore::new(MAX_PENDING_DYNAMIC_TOOL_CALLS / 2);
for req in requests {
let _permit = sem.acquire().await;
runtime.register_dynamic_tool_call(req).await?;
} Defensive patterns
Strategy: try-catch
Validate before calling
if runtime.pending_dynamic_tool_call_count() >= MAX_PENDING_DYNAMIC_TOOL_CALLS {
// drain pending results before registering more
} Try / catch
match runtime.register_dynamic_tool_call(params) {
Err(e) if e.to_string().contains("pending dynamic tool call limit") => {
settle_pending_calls(&mut pending).await;
runtime.register_dynamic_tool_call(params).await?;
}
other => other?,
} Prevention
- Always await the oneshot receiver for each dynamic tool call
- Cap concurrency with a semaphore sized below the limit
- Watch for consumers that stop draining settlement receivers (leaks count against the cap)
When it happens
Trigger: Calling the dynamic-tool-call registration API when pending_dynamic_tools already holds the maximum number of unresolved calls (each awaiting its oneshot result).
Common situations: Firing many parallel dynamic tool invocations without awaiting results; a consumer that stopped draining settlement receivers, leaking pending entries; runaway agent loops requesting tools faster than they settle.
Related errors
- A saved trace identifier collided. Try saving again.
- a window change is already in progress
- accepted_requests must equal requests_attempted; sender…
- another Codewhale process
- Another pet recorder is using this output.
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/8be589f91505065a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/runtime_threads.rs:5485
.map(|(_, entry)| entry.request.clone())
.collect::<Vec<_>>();
user_inputs.sort_by(|left, right| {
left.turn_id
.cmp(&right.turn_id)
.then_with(|| left.id.cmp(&right.id))
});
(approvals, user_inputs)
}
fn register_pending_dynamic_tool(
&self,
params: DynamicToolCallParams,
) -> Result<oneshot::Receiver<DynamicToolCallResult>> {
let (tx, rx) = oneshot::channel();
let (settlement_tx, _settlement_rx) = watch::channel(0);
let mut pending = self.pending_dynamic_tools.lock();
if pending.len() >= MAX_PENDING_DYNAMIC_TOOL_CALLS {
bail!(
"Runtime has reached the pending dynamic tool call limit ({MAX_PENDING_DYNAMIC_TOOL_CALLS})"
);
}
if pending.contains_key(¶ms.call_id) {
bail!("Dynamic tool call '{}' is already pending", params.call_id);
}
pending.insert(
params.call_id.clone(),
PendingDynamicToolEntry {
params,
sender: Some(tx),
settlement_tx,
indeterminate: false,
},
);
Ok(rx)
}
View on GitHub (pinned to 73e0f67d83)