(project-folder-identifier)(project-folder-identifier project-dir)Builds a stable identifier for a project directory.
Builds a stable identifier for a project directory.
(prompt-send! {:keys [agent provider prompt] :as request})Sends a prompt request map through a provider.
Required request keys:
:agent:promptOptional request keys:
:provider to use for this call without mutating the connected provider:model, :temperature, :top-p,
:max-tokens, :stop, :tools, :tool-choice, :response-format,
:metadata, and similar fields:provider-step-limit to set an explicit positive loop cap; otherwise the
provider/tool loop is unlimited:step-modifier and :session-modifier
where:
:step-modifier receives
{:agent ... :provider ... :provider-entry ... :request ... :response nil :session ... :step ...}
plus a handler function. Call (handler updated-context) to continue the
provider step and receive the resulting context with :response, for example
(fn [{:keys [request step] :as context} handler] (prn :step-request step (:prompt request)) (let [result (handler (assoc context :request (update request :prompt str "!")))] (prn :step-response step (:response result)) result)):session-modifier receives the live session context and must return the
updated context map containing :session, for example
(fn [{:keys [phase session] :as context}] (if (= phase :after-provider) (assoc context :session (update session :messages subvec 1)) context)):prompt may be:
Prompt entries may be strings, {:role ... :content ...} maps, or single-key
maps like {:system "..."} and {:user "..."}.
Returns:
:prompt is sequential: an atom containing the in-flight session mapSends a prompt request map through a provider.
Required request keys:
- `:agent`
- `:prompt`
Optional request keys:
- `:provider` to use for this call without mutating the connected provider
- provider request options like `:model`, `:temperature`, `:top-p`,
`:max-tokens`, `:stop`, `:tools`, `:tool-choice`, `:response-format`,
`:metadata`, and similar fields
- `:provider-step-limit` to set an explicit positive loop cap; otherwise the
provider/tool loop is unlimited
- `:step-modifier` and `:session-modifier`
where:
- `:step-modifier` receives
`{:agent ... :provider ... :provider-entry ... :request ... :response nil :session ... :step ...}`
plus a `handler` function. Call `(handler updated-context)` to continue the
provider step and receive the resulting context with `:response`, for example
`(fn [{:keys [request step] :as context} handler]
(prn :step-request step (:prompt request))
(let [result (handler (assoc context :request (update request :prompt str "!")))]
(prn :step-response step (:response result))
result))`
- `:session-modifier` receives the live session context and must return the
updated context map containing `:session`, for example
`(fn [{:keys [phase session] :as context}]
(if (= phase :after-provider)
(assoc context :session (update session :messages subvec 1))
context))`
- provider-level step modifiers wrap per-request step modifiers
- these hooks are middleware-like around wrappers, so one hook can observe
and change both the request and the response for a single provider step
`:prompt` may be:
- a string
- a single prompt map
- a sequential collection of prompt entries
Prompt entries may be strings, `{:role ... :content ...}` maps, or single-key
maps like `{:system "..."}` and `{:user "..."}`.
Returns:
- when `:prompt` is sequential: an atom containing the in-flight session map
- otherwise: the final provider response(provider-connect! agent provider-ref)(provider-connect! agent provider-name provider-ref)Connects the agent to a provider.
Supported forms:
[agent provider-ref][agent provider-name provider-ref]provider-ref may be:
:invoke function and optional :name, :kind,
:endpoint, :model, :step-modifier, and
:session-modifierprovider-name overrides the inferred provider name when supplied.
Provider maps may also supply:
:step-modifier - function, var, or symbol called around each normalized
provider step with {:agent ... :provider ... :provider-entry ... :request ... :response nil :session ... :step ...} plus a handler function. Call
(handler updated-context) to continue the provider step and receive the
resulting context with :response. Example:
(fn [{:keys [request step] :as context} handler] (prn :step-request step (:prompt request)) (let [result (handler (assoc context :request (update request :prompt str "!")))] (prn :step-response step (:response result)) result)):session-modifier - function, var, or symbol called with the live session
context map and phase data, and expected to return the updated context map
containing :sessionConnects the agent to a provider.
Supported forms:
- `[agent provider-ref]`
- `[agent provider-name provider-ref]`
`provider-ref` may be:
- a provider map with an `:invoke` function and optional `:name`, `:kind`,
`:endpoint`, `:model`, `:step-modifier`, and
`:session-modifier`
- a var, function, or resolvable symbol that yields such a provider map or a
plain callable
`provider-name` overrides the inferred provider name when supplied.
Provider maps may also supply:
- `:step-modifier` - function, var, or symbol called around each normalized
provider step with `{:agent ... :provider ... :provider-entry ... :request
... :response nil :session ... :step ...}` plus a `handler` function. Call
`(handler updated-context)` to continue the provider step and receive the
resulting context with `:response`. Example:
`(fn [{:keys [request step] :as context} handler]
(prn :step-request step (:prompt request))
(let [result (handler (assoc context :request (update request :prompt str "!")))]
(prn :step-response step (:response result))
result))`
- `:session-modifier` - function, var, or symbol called with the live session
context map and phase data, and expected to return the updated context map
containing `:session`(provider-current agent)Returns the connected provider summary, if any.
Returns the connected provider summary, if any.
(provider-disconnect! agent)Disconnects the current provider and returns its summary when one was set.
Disconnects the current provider and returns its summary when one was set.
(session-read path)Reads a persisted session file as a session map.
Reads a persisted session file as a session map.
(sessions-directory agent)Returns the directory where this agent stores prompt sessions.
The path is derived from the agent's :sessions-root and :project-dir.
Returns the directory where this agent stores prompt sessions. The path is derived from the agent's `:sessions-root` and `:project-dir`.
(sessions-list agent)Lists persisted session files for an agent.
Lists persisted session files for an agent.
(sessions-root-default)Returns the default root directory for stored sessions.
Returns the default root directory for stored sessions.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |