ol.llx.agent
platforms: clj, cljs
Public runtime wrapper for the agent loop.
This namespace wires runtime state, effect environment dependencies, and subscription management around `ol.llx.agent.loop` + `ol.llx.agent.fx`.
default-convert-to-llm
clj
platforms: clj
(default-convert-to-llm messages)
Converts agent messages to LLM-compatible messages by keeping only maps
whose :role is one of :user, :assistant, or :tool-result.
cljs
platforms: cljs
(default-convert-to-llm messages)
Converts agent messages to LLM-compatible messages by keeping only maps
whose :role is one of :user, :assistant, or :tool-result.
create-agent
clj
platforms: clj
(create-agent)
(create-agent opts)
Creates an agent runtime handle.
Required options: - `:tools` vector of tools
`opts` may include:
- `:convert-to-llm` `(fn [messages])`; defaults to filtering
messages to roles `:user`, `:assistant`,
`:tool-result`
- `:transform-context` optional context transform hook
- `:stream-fn` optional stream hook; resolved at callsite
- `:schema-registry` extra Malli registry to be composed with the built-in schemas
- `:custom-message-schemas` map of message dispatch keyword to schema keyword in the active registry
- `:session-id`, `:get-api-key`, `:thinking-budgets`, `:max-retry-delay-ms`
- `:system-prompt`, `:model`, `:thinking-level`
- `:steering-mode`, `:follow-up-mode`
- `:abort-signal`
For state rehydration, use rehydrate-agent.
cljs
platforms: cljs
(create-agent)
(create-agent opts)
Creates an agent runtime handle.
Required options: - `:tools` vector of tools
`opts` may include:
- `:convert-to-llm` `(fn [messages])`; defaults to filtering
messages to roles `:user`, `:assistant`,
`:tool-result`
- `:transform-context` optional context transform hook
- `:stream-fn` optional stream hook; resolved at callsite
- `:schema-registry` extra Malli registry to be composed with the built-in schemas
- `:custom-message-schemas` map of message dispatch keyword to schema keyword in the active registry
- `:session-id`, `:get-api-key`, `:thinking-budgets`, `:max-retry-delay-ms`
- `:system-prompt`, `:model`, `:thinking-level`
- `:steering-mode`, `:follow-up-mode`
- `:abort-signal`
For state rehydration, use rehydrate-agent.
rehydrate-agent
clj
platforms: clj
(rehydrate-agent state opts)
Creates an agent runtime from a previously persisted state snapshot.
`state` must satisfy `:ol.llx.agent.loop/state`. `opts` carries runtime dependencies and may include: - `:convert-to-llm` (optional; see <<create-agent,`create-agent`>>) - `:transform-context` (optional; see <<create-agent,`create-agent`>>) - `:stream-fn` (optional; see <<create-agent,`create-agent`>>) - `:schema-registry` (optional; see <<create-agent,`create-agent`>>) - `:custom-message-schemas` (optional; see <<create-agent,`create-agent`>>) - `:session-id`, `:get-api-key`, `:thinking-budgets`, `:max-retry-delay-ms` - `:tools` - `:abort-signal`.
cljs
platforms: cljs
(rehydrate-agent state opts)
Creates an agent runtime from a previously persisted state snapshot.
`state` must satisfy `:ol.llx.agent.loop/state`. `opts` carries runtime dependencies and may include: - `:convert-to-llm` (optional; see <<create-agent,`create-agent`>>) - `:transform-context` (optional; see <<create-agent,`create-agent`>>) - `:stream-fn` (optional; see <<create-agent,`create-agent`>>) - `:schema-registry` (optional; see <<create-agent,`create-agent`>>) - `:custom-message-schemas` (optional; see <<create-agent,`create-agent`>>) - `:session-id`, `:get-api-key`, `:thinking-budgets`, `:max-retry-delay-ms` - `:tools` - `:abort-signal`.
subscribe
clj
platforms: clj
(subscribe agent)
(subscribe agent ch)
Subscribes a channel to the agent event stream.
-
(subscribe agent)creates and returns a buffered channel. -
(subscribe agent ch)taps the provided channel and returns it.
cljs
platforms: cljs
(subscribe agent)
(subscribe agent ch)
Subscribes a channel to the agent event stream.
-
(subscribe agent)creates and returns a buffered channel. -
(subscribe agent ch)taps the provided channel and returns it.
wait-for-idle
clj
platforms: clj
(wait-for-idle agent)
(wait-for-idle agent max-polls)
Waits until the agent reaches :ol.llx.agent.loop/idle or :ol.llx.agent.loop/closed.
Resolves `true` when idle/closed, or `false` after the polling budget is exhausted.
cljs
platforms: cljs
(wait-for-idle agent)
(wait-for-idle agent max-polls)
Waits until the agent reaches :ol.llx.agent.loop/idle or :ol.llx.agent.loop/closed.
Resolves `true` when idle/closed, or `false` after the polling budget is exhausted.