pub async fn emit_after_tool_call(
hook_bus: &Arc<HookBus>,
tool_name: &str,
runtime_tool_name: Option<&str>,
input: Value,
output: String,
max_tool_output: usize,
) -> StringExpand description
Emit an after_tool_call event and return the tool output to record in
history — either the original output, or a Replace { output }
substituted by an extension transform hook (compression, redaction,
summarization). The runtime tool name is included when it differs from the
API-safe name.
Fail-safe: any non-Replace result — Continue, a result rejected by the
permission matrix, a crashed/timed-out handler, or any future variant —
returns the original output unchanged. A misbehaving extension can never
drop or corrupt a tool’s output.
Note: the event delivered to the extension carries tool_output as a
size-limited preview for large outputs — a ~256 KB prefix plus a
…[truncated, N total bytes] marker (see [HookEvent::after_tool_call]),
matching max_tool_buffer. The final returned string is then truncated to
max_tool_output (the context budget) — compress-then-truncate ordering,
so a transform extension sees the full buffered output and decides what to
keep before the hard cap is applied.