Skip to content

ACP host hooks — permission, updates, cancel, stream

Java · package io.github.muthuishere:toolnexus · SPEC §8

Opt-in hooks on an ACP model source: choose the permission option, watch every session/update, cancel a turn, and stream through an in-process client.

Java ships io.github.muthuishere.toolnexus.acp.AcpClient: AcpClient.start(command) spawns the agent over stdio, keeps one warm session, and plugs into the loop as an in-process model (it implements Function<InProcess.Request, InProcess.Response>). What it does today, in place of each Go hook:

  • Permission — autoAnswerPermission (default true) answers every session/request_permission with the first allow-kind option. There is no host callback, so a plan mode or a human approval prompt is not possible yet; restrict the agent with its own mode instead (acp.setMode(modeId)).
  • Updates — only agent_message_chunk text forms the reply; other session/update notifications are not surfaced to the host.
  • Cancel — timeoutMs (default 10 s) bounds each session/prompt, and close() stops the agent. There is no per-turn session/cancel.
  • Streaming — not available through an ACP model; use LlmClient.run.

If you need these hooks now, use the Go port (ACPOptions.OnPermission, OnUpdate, ACPClient.GenerateCtx, ACPClient.GenerateStream); see the Go page.

  • LlmClient.create — The unified client: system prompt, skills injection, parallel and chained tool calls, retries, memory.
  • LlmClient.run — Send a prompt, let the loop call tools until the model stops, get a RunResult.
  • LlmClient.stream — The streaming loop: text deltas, tool-call events, and suspension events as they happen.
  • LlmClient.Hooks — Intercept before/after model calls and tool calls: audit, redact, veto, or rewrite.