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` user-owned extra Malli schemas
- `:custom-message-schemas` user-owned custom message dispatch map
- `: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` user-owned extra Malli schemas
- `:custom-message-schemas` user-owned custom message dispatch map
- `: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`>>) - `: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`>>) - `: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.
set-schema-config
clj
platforms: clj
(set-schema-config agent schema-config-update)
Replaces the agent’s user-owned schema configuration.
schema-config-update may include :schema-registry and/or
:custom-message-schemas. nil for either field preserves the current
user-owned value.
This setter is accepted in any phase. It affects future validation and future tool execution only; already queued messages and already running tool executions keep using the registry they started with.
cljs
platforms: cljs
(set-schema-config agent schema-config-update)
Replaces the agent’s user-owned schema configuration.
schema-config-update may include :schema-registry and/or
:custom-message-schemas. nil for either field preserves the current
user-owned value.
This setter is accepted in any phase. It affects future validation and future tool execution only; already queued messages and already running tool executions keep using the registry they started with.