Liking cljdoc? Tell your friends :D

Bedrock AgentCore SDK for Clojure

⚠️ UNOFFICIAL SDK: This is an unofficial, community-maintained Clojure SDK for Amazon Bedrock AgentCore. It is not officially supported by AWS.

Deploy your local AI agent to Bedrock AgentCore with zero infrastructure using Clojure.

🚀 Quick Start

;; Your existing agent logic
(defn my-local-agent [query]
  ;; Your carefully crafted agent logic
  (str "Response to: " (:prompt query)))

;; Deploy to Bedrock AgentCore
(require '[bedrock-agentcore.core :as agentcore])

(def app (agentcore/create-app))

(def production-app
  (agentcore/entrypoint app
    (fn [request]
      (my-local-agent request))))  ; Same logic, enterprise platform

(agentcore/run-app production-app)  ; Ready to run on Bedrock AgentCore

What you get with Bedrock AgentCore:

  • Keep your agent logic - Works with any Clojure-based agent framework
  • Zero infrastructure management - No servers, containers, or scaling concerns
  • Enterprise-grade platform - Built-in auth, memory, observability, security
  • Production-ready deployment - Reliable, scalable, compliant hosting

Installation

Add to your project.clj:

[bedrock-agentcore "1.0.0"]

Or for Leiningen:

lein new app my-agent
cd my-agent

Core Features

1. Basic Agent

(ns my-agent.core
  (:require [bedrock-agentcore.core :as agentcore]))

(defn simple-agent [request]
  {:response (str "Hello, " (get request "name" "World"))
   :timestamp (System/currentTimeMillis)})

(def app
  (-> (agentcore/create-app)
      (agentcore/entrypoint simple-agent)))

(agentcore/run-app app {:port 8080})

2. Agent with Memory

(ns my-agent.memory
  (:require [bedrock-agentcore.core :as agentcore]
            [bedrock-agentcore.memory :as memory]))

(def memory-client (memory/create-memory-client))

(defn memory-agent [request]
  (let [context (agentcore/get-request-context)
        session-id (:session-id context)
        namespace "my-agent"]
    
    ;; Store conversation in memory
    (memory/store-memory memory-client namespace session-id
                        {:user-input (:prompt request)
                         :timestamp (System/currentTimeMillis)})
    
    ;; Retrieve past conversations
    (let [memories (memory/retrieve-memory memory-client namespace session-id)]
      {:response "I remember our past conversations!"
       :memory-count (count (:memories memories))})))

(def app
  (-> (agentcore/create-app)
      (agentcore/entrypoint memory-agent)
      (agentcore/add-middleware (memory/with-memory memory-client "my-agent"))))

(agentcore/run-app app)

3. Agent with Tools

(ns my-agent.tools
  (:require [bedrock-agentcore.core :as agentcore]
            [bedrock-agentcore.tools :as tools]))

(defn tool-agent [request]
  (let [context (agentcore/get-request-context)
        session-id (:session-id context)
        code-tool (tools/create-code-interpreter session-id)
        browser-tool (tools/create-browser session-id)]
    
    (case (:action request)
      "code" (tools/execute code-tool (:code request))
      "browse" (tools/execute browser-tool (:url request))
      {:response "Available actions: code, browse"})))

(def app
  (-> (agentcore/create-app)
      (agentcore/entrypoint tool-agent)))

(agentcore/run-app app)

4. Advanced Agent with All Features

(ns my-agent.advanced
  (:require [bedrock-agentcore.core :as agentcore]
            [bedrock-agentcore.memory :as memory]
            [bedrock-agentcore.tools :as tools]
            [clojure.tools.logging :as log]))

(def memory-client (memory/create-memory-client))

(defn advanced-agent [request]
  (let [context (agentcore/get-request-context)
        session-id (:session-id context)
        namespace "advanced-agent"]
    
    (log/info "Processing request" {:session-id session-id})
    
    ;; Retrieve memories
    (let [memories (memory/retrieve-memory memory-client namespace session-id)
          tools-map {:code (tools/create-code-interpreter session-id)
                     :browser (tools/create-browser session-id)}]
      
      ;; Store current interaction
      (memory/store-memory memory-client namespace session-id
                          {:input (:prompt request)
                           :timestamp (System/currentTimeMillis)})
      
      {:response (str "Advanced agent response to: " (:prompt request))
       :memory-count (count (:memories memories))
       :available-tools (keys tools-map)
       :session-id session-id})))

(def app
  (-> (agentcore/create-app)
      (agentcore/entrypoint advanced-agent)
      (agentcore/add-middleware (memory/with-memory memory-client "advanced-agent"))))

(agentcore/run-app app {:port 8080})

API Reference

Core Functions

  • (create-app) - Create a new Bedrock AgentCore application
  • (entrypoint app handler-fn) - Set the main handler function
  • (add-middleware app middleware-fn) - Add middleware to the application
  • (run-app app options) - Start the application server
  • (get-request-context) - Get current request context (session-id, request-id, etc.)

Memory Functions

  • (create-memory-client) - Create a memory client
  • (store-memory client namespace session-id content) - Store memory
  • (retrieve-memory client namespace session-id) - Retrieve memory
  • (delete-memory client namespace session-id) - Delete session memory
  • (delete-all-memory client namespace) - Delete all memory in namespace

Tool Functions

  • (create-code-interpreter session-id) - Create code execution tool
  • (create-browser session-id) - Create browser automation tool
  • (execute tool input) - Execute a tool with input

Configuration

Set environment variables:

export AWS_REGION=us-east-1
export AWS_ACCESS_KEY_ID=your-key
export AWS_SECRET_ACCESS_KEY=your-secret

Running Your Agent

# Development
lein run

# Production build
lein uberjar
java -jar target/uberjar/my-agent-standalone.jar

Amazon Bedrock AgentCore Services

This SDK provides simplified access to:

  • 🚀 Runtime - Secure and session isolated compute
  • 🧠 Memory - Persistent knowledge across sessions
  • 💻 Code Interpreter - Secure sandboxed execution
  • 🌐 Browser - Cloud-based web automation

Deployment

Use the Bedrock AgentCore Starter Toolkit for deployment to AWS.

License

Apache 2.0 - This unofficial SDK follows the same license as the official AWS SDKs.

Contributing

This is a community project. Contributions welcome! Please ensure all contributions maintain security best practices.

Support

For official Bedrock AgentCore support, see the official documentation.

For this unofficial Clojure SDK, please create issues in the repository.

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