子 Agent 委派工具构建器(对标 beamai_agent_delegate)
提供三类入口:
delegate-tool:spawn→await→drop,同步拿结果。fanout-tool:tasks 列表,并发启动多个子 agent,汇总。management-tools:spawn/list/result/kill/restart,供 LLM 跨轮自管。每个函数返回内联工具 map(含 :handler),可直接放入 :tools 列表。
三类入口的 config 都认一个可选的 :observer——协议无关的观察挂点,
原样透进 manager/spawn! 的 spec(契约见 manager 的 ns docstring)。
AG-UI 那侧用它把委派期间的 token / 工具调用归属到一条 lane
(docs/subagent-event-attribution-design.md);不传就是今天的行为,逐字不变。
使用示例: (def research-tool (delegate-tool {:name "deep_research" :subagent-fn (fn [_ _] {:provider p :model "gpt-4o"}) :timeout 120000})) (create-agent {:tools [#'my-tool research-tool] ...})
子 Agent 委派工具构建器(对标 beamai_agent_delegate)
提供三类入口:
1. **同步单委派** `delegate-tool`:spawn→await→drop,同步拿结果。
2. **同步并发 fan-out** `fanout-tool`:tasks 列表,并发启动多个子 agent,汇总。
3. **异步管理工具集** `management-tools`:spawn/list/result/kill/restart,供 LLM 跨轮自管。
每个函数返回**内联工具 map**(含 :handler),可直接放入 :tools 列表。
三类入口的 config 都认一个可选的 `:observer`——**协议无关的观察挂点**,
原样透进 `manager/spawn!` 的 spec(契约见 `manager` 的 ns docstring)。
AG-UI 那侧用它把委派期间的 token / 工具调用归属到一条 lane
(docs/subagent-event-attribution-design.md);不传就是今天的行为,逐字不变。
使用示例:
(def research-tool
(delegate-tool {:name "deep_research"
:subagent-fn (fn [_ _] {:provider p :model "gpt-4o"})
:timeout 120000}))
(create-agent {:tools [#'my-tool research-tool] ...})(delegate-tool config)构建单委派工具(同步:spawn→await→drop)。
config 键:
返回内联工具 map,可放入 :tools 列表。
构建单委派工具(同步:spawn→await→drop)。 config 键: - :name 工具名(必需) - :description 工具描述(可选) - :subagent-fn (fn [args ctx] -> subagent-config)(必需) - :seed-fn (fn [args ctx] -> prompt-prefix)(可选) - :result-fn (fn [chat-result] -> string)(可选,默认取 :text) - :timeout 超时毫秒(可选,默认 60000) - :observer 观察者工厂(可选,见 ns docstring) - :subagent-name 给观察者看的子 agent 名(可选,缺省取工具名) 返回内联工具 map,可放入 :tools 列表。
(fanout-tool config)构建并发 fan-out 委派工具。
LLM 传入 tasks 列表,每个任务独立 spawn 子 agent 并发执行,汇总所有结果。 config 键同 delegate-tool。
构建并发 fan-out 委派工具。 LLM 传入 tasks 列表,每个任务独立 spawn 子 agent 并发执行,汇总所有结果。 config 键同 delegate-tool。
(management-tools config)返回一组异步管理工具(5 个内联工具 map),让 LLM 跨轮自主管理子 agent。
工具列表:spawn_subagent / list_subagents / subagent_result / kill_subagent / restart_subagent
config 键同 delegate-tool。
用法: (create-agent {:tools (into [#'my-tool] (delegate/management-tools my-config))})
返回一组异步管理工具(5 个内联工具 map),让 LLM 跨轮自主管理子 agent。
工具列表:spawn_subagent / list_subagents / subagent_result / kill_subagent / restart_subagent
config 键同 delegate-tool。
用法:
(create-agent {:tools (into [#'my-tool] (delegate/management-tools my-config))})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 |