Liking cljdoc? Tell your friends :D

Client API

Module: im.ttalk/clj-agent-client

Source: modules/clj-agent-client/src

SimpleAgent

Namespace: im.ttalk.agent.simple-agent

SimpleAgent is the recommended high-level API. It owns one conversation id, stores history through a ChatMemory filter, runs the ReAct loop, and normalizes pause and error outcomes.

FunctionPurpose
create-agentCreate an agent from provider/model/tools/memory/options
chatSynchronous conversation turn
chat-streamStreaming turn; callback receives incremental token events
chat-asyncTurn returning a CompletableFuture
resumeContinue a paused turn after an approval decision
resume-asyncAsynchronous resume
paused?Whether the agent has a pending pause state
get-historyNeutral message history for the current conversation
reset!Clear history and reset control state

Status shapes:

{:status :completed :text "..."}
{:status :paused :reason ... :pending-tool {...}}
{:status :error :error {:type ... :message ... :retryable? ...}}

Do not share one non-thread-safe SimpleAgent across concurrent turns for the same conversation. Use the AG-UI runtime when runs must survive or be controlled from independent HTTP requests.

ReAct loop

Namespace: im.ttalk.agent.react

Most applications use SimpleAgent rather than calling the loop directly. The loop owns these extension points:

Function/constructorContract
invokeRun one complete tool-calling turn
invoke-asyncAsync variant on a virtual thread
resumeContinue from a paused loop state
execute-batchMapReduce execution for one tool batch
sequential-tool-calling-managerDefault serial engine
virtual-thread-tool-calling-managerOne virtual thread per eligible call
thread-pool-tool-calling-managerBounded, instance-owned platform pool
shutdown-tool-calling-manager!Release engine resources

A bounded tool manager belongs to one ChatClient. Do not share it across parent and subagent clients; doing so can deadlock when both levels wait for the same pool.

Memory and stores

  • im.ttalk.agent.memory: ChatMemory protocol, in-memory-store, and windowed.
  • im.ttalk.agent.memory.sqlite: sqlite-store and close-store!.
  • im.ttalk.agent.pause: PauseStore protocol plus in-memory and SQLite stores.
  • im.ttalk.agent.timeline: branch records, fork!, rollback!, prune!, and lineage queries.

Memory stores persist neutral messages by conversation id. SQLite-backed stores should be closed on application shutdown.

Approval and events

  • im.ttalk.agent.approval: policies, approver chains, session cache, denial breaker, and approval-filter.
  • im.ttalk.agent.approval.model: optional model-based reviewer.
  • im.ttalk.agent.events: closed set of turn lifecycle events and a zero-dependency metrics collector.
  • im.ttalk.agent.callbacks: safe lifecycle callback dispatch.

The default policy pauses :sensitive tools when approval is configured. A resume decision is normally "approved" or "rejected"; payload support depends on the pending tool.

Subagents

  • im.ttalk.agent.subagent.manager: spawn, await, result, resume, kill, restart, and list subagent runs.
  • im.ttalk.agent.subagent.delegate: synchronous delegate/fan-out tools.
  • im.ttalk.agent.subagent.tools: async spawn/send/wait/list/interrupt tools with agent-count and depth limits.

Subagents are independent agents with their own client and tool manager. Use the observer hook when parent events must attribute child activity.

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close