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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Context construction strategies — one entry point per model/provider.
//!
//! This module owns the [`CtxBuilder`] trait (defined below) and the
//! registry function [`for_provider`] (in [`resolver`]). Each concrete
//! builder lives in its own file to keep [`mod.rs`](self) thin:
//!
//! | File | Role |
//! |---------------|-------------------------------------------------------|
//! | `mod.rs` | `CtxBuilder` trait definition + re-exports |
//! | `resolver.rs` | `for_provider` dispatch (add new models here) |
//! | `render.rs` | Default render / compression-plan policy |
//! | `default.rs` | `DefaultCtx` — thin wrapper over `render` |
//! | `ollama.rs` | `OllamaCtx` — small-window local models |
//! | `truncate.rs` | Shared per-tool truncation helpers |
//!
//! Adding a new per-model ctx strategy:
//!
//! 1. Create `ctx/<name>.rs` with a `pub struct XxxCtx` and
//! `impl CtxBuilder for XxxCtx`. Keep all ctor + tests + impl
//! methods in that single file.
//! 2. Declare `pub mod <name>;` below.
//! 3. Register in `resolver::for_provider`.
//!
//! The trait is narrow on purpose: `build_messages` owns the full
//! render path for its model, including any system-prompt variation,
//! cold-zone handling, or tool-schema trimming. The shared
//! [`render`] and [`truncate`] modules offer building blocks that
//! impls may call or ignore at will.
use crateMessage;
use crate;
use crateToolResult;
pub use DefaultCtx;
pub use EnvSnapshot;
pub use OllamaCtx;
pub use for_provider;
/// Per-session context construction strategy. Selected once at
/// `AgentLoop::new` via [`for_provider`] and rebuilt on `ReloadConfig`.