1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Request-scoped tool construction.
//!
//! The dev server (and any host that serves many agent runs) must build some
//! tools **per request** because they carry per-run state — most notably the
//! built-in `task` tool ([`crate::subagent::TaskTool`]), which owns the run's
//! cancellation token, event sink, and delegation budget. Reusing one across
//! requests would cross-wire cancellation and events between concurrent runs.
//!
//! [`ToolRequestContext`] bundles exactly the per-run inputs a tool factory
//! needs, and [`ToolFactory`] is the type-erased closure a host stores to turn
//! that context into a concrete tool list. See `docs/DEV_CONFIG_UX_DESIGN.md`.
use Arc;
use CancellationToken;
use crateEventSink;
use crate;
use crateToolPolicy;
use crateRunConfig;
use crateTool;
/// Inputs needed to build a single request's tool list. Passed **by value**
/// into a [`ToolFactory`] so the factory can construct request-local tools
/// (e.g. a fresh top-level `TaskTool` bound to this run's cancel token + sink).
///
/// The `provider` / `parent_model` / `parent_config` are the agent's values
/// (the same for every request of that agent); only `cancel` + `event_sink`
/// vary per request. They are bundled together so the factory signature stays
/// a single argument.
/// Builds the full tool list for a single request.
///
/// Stored on a server's agent handle; when set, it takes precedence over any
/// static tool list. The closure must be `Send + Sync` (called concurrently
/// from many request tasks) and `Clone`-cheap (it is an `Arc`).
pub type ToolFactory = ;