Framework

clj-agent · The AI agent framework for Clojure

clj-agent is an agentic AI toolkit written in Clojure: the deftool macro declares tools and generates parameter descriptions for the model automatically, ChatClient unifies tool dispatch, and around-style filters handle cross-cutting logic.

It splits into core (protocols and ChatClient primitives, zero external dependencies), client (the agent runtime: ReAct loop, memory, pause / resume), and provider (vendor adapters). It runs on the JVM and drops straight into Ring / Luminus applications.

A complete path from simple chat to tool calling

Clojure: declare a tool and create an agent
(require '[im.ttalk.agent.simple-agent :as sa]
         '[im.ttalk.agent.tool :refer [deftool]]
         '[im.ttalk.agent.provider.factory.builder :as factory])

(deftool get-weather "Get the weather" [[city :string "City name"]]
  (str city ": sunny, 25°C"))

(def provider (factory/create-provider-from-env :openai))
(def agent (sa/create-agent {:provider provider :model "gpt-4"
                             :tools [#'get-weather]}))
(println (:text (sa/chat agent "How's the weather in Beijing?")))

Features

What it can do

  • deftool

    One macro declares a tool: name, description, and typed, documented parameters — the model-facing description is generated automatically.

  • ChatClient and filters

    Unified tool dispatch and orchestration with around-style filter middleware; five hook types: :chat, :tool, :iteration, :turn, and :token-xform.

  • SimpleAgent

    Synchronous, stateful multi-turn conversation; pauses before sensitive tool calls and resumes after human approval.

  • Aligned with Spring AI 2.0

    ToolSearch (progressive tool disclosure), RAG injection, and structured output validation.

  • Multimodal and embeddings

    Images, PDFs, and audio as message content; a standalone IEmbeddingProvider protocol covering several embedding services.

  • Async

    CompletableFuture-based async, playing well with virtual threads — a fit for Ring / Luminus servers.

Specifications

Technical specifications

RuntimeJVM, Clojure 1.11.4+; built with babashka and tools.build
Modulesclj-agent-core (zero external deps), clj-agent-client (agent runtime), clj-agent-provider (vendor adapters)
VendorsOpenAI, Anthropic, DeepSeek, Zhipu, Ollama, Gemini, Mistral, MiniMax, DashScope, xAI, Moonshot, OpenRouter, SiliconFlow, plus OpenAI-compatible protocols
Coordinatesim.ttalk/clj-agent (git dependency, tag v0.3.0)
LicenseApache License 2.0

FAQ

You might be wondering

How do I add the dependency?

In deps.edn, as a git dependency: {im.ttalk/clj-agent {:git/url "https://github.com/TTalkPro/clj-agent" :git/tag "v0.3.0"}}.

Relationship with BeamAI?

The same agent architecture on two platforms: clj-agent targets the JVM / Clojure and BeamAI targets Erlang/OTP, both built around ChatClient, tools, and filters.

What is the license?

Apache License 2.0, fine for commercial projects.

Open source

Apache 2.0 open source

The engine, tests, benchmarks, and design docs are all in the repository — read them, change them, file issues.

Related framework

BeamAI · The AI agent framework for Erlang/OTP

Build AI agents on Erlang/OTP: a unified LLM client across six vendors, ChatClient and tool calling, onion-style filters, and a ReAct agent with conversation memory.