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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//! Declared context profiles for the catalog models whose context Agentty
//! manages: Codex app-server compaction and native harness registrations.
//!
//! Harness models declare estimators fitted on 2026-10-18 to live
//! provider-reported input tokens: the `ag-harness` benchmark `estimate`
//! suite's synthetic probes plus recorded Agentty harness requests, each
//! with the 7.4 KB protocol schema and the `read`, `write`, and `bash`
//! definitions
//! (`crates/ag-harness/tests/benchmark/results/2026-10-18-estimate-probes.
//! jsonl`). Errors below are provider tokens over estimated tokens, minus one,
//! on those recorded requests, replayed without tool-call reasoning to the
//! models that never receive it. Content denser than repository text, such
//! as digit-heavy generated code, still runs 30–46% over every fitted
//! estimate, which runtime calibration absorbs.
//!
//! Each harness profile's estimate margin tolerates the largest under-count
//! its estimator showed, rounded up, plus five points: on those recorded
//! requests, or on one live request fitted near the input budget from this
//! repository's Rust sources read whole (`ag-harness` live test
//! `test_estimate_margin_near_window`), which ran +12.6% over the estimate on
//! Muse Spark 1.3, +11.9% on Kimi K3, +9.0% on Qwen-Plus, +7.7% on
//! Qwen3.8-Max, and +7.6% on Kimi K2.6. Kimi K2.6 shares Kimi K3's tokenizer
//! and margin. Calibration learns denser content only from the next usage
//! report, and a full budget leaves 113,000–140,000 tokens beside its
//! prediction on the 1M windows and 33,000 on Kimi K2.6: one maximal 50 KB
//! `read` of digits, which Qwen tokenizes one per digit, misses about 39,000
//! Qwen tokens and 12,000 Kimi tokens. Content denser still overflows the
//! window, and the harness re-sends the request within 75% of the rejected
//! weight, which fits content up to 53–57% over the estimate.
use ;
use AgentModel;
/// Codex Astra, Sol, Luna, and Terra: 1,050,000-token window with 128,000
/// tokens held back for output and provider overhead before compaction. The
/// reservation is an input-budget policy, not a maximum output limit.
const CODEX_LARGE: ModelProfile = new.with_reserved_tokens;
/// Codex Spark: 128,000-token window with 8,000 tokens held back for output
/// and provider overhead before compaction.
const CODEX_SPARK: ModelProfile = new.with_reserved_tokens;
/// Kimi K2.6: documented and enforced 262,144-token window with a
/// 32,768-token default `max_tokens`.
const KIMI_K2_6: ModelProfile = new
.with_estimate_margin
.with_estimator;
/// Kimi K3: documented 1M (1,048,576-token) window with a 131,072-token
/// default `max_completion_tokens`.
const KIMI_K3: ModelProfile = new
.with_estimate_margin
.with_estimator;
/// Muse Spark 1.3: documented 1,048,576-token window and an undocumented
/// output limit, reserved at the 131,072 tokens the API accepts.
const MUSE_SPARK_1_3: ModelProfile = new
.with_estimate_margin
.with_estimator;
/// Qwen3.8-Max: documented 1,000,000-token window, 983,616-token thinking
/// input limit, and 131,072-token output limit.
const QWEN3_8_MAX: ModelProfile = new
.with_estimate_margin
.with_estimator;
/// Qwen-Plus: documented 1,000,000-token window, 995,904-token thinking
/// input limit, and 32,768-token output limit.
const QWEN_PLUS: ModelProfile = new
.with_estimate_margin
.with_estimator;
/// Kimi K2.6 (JSON Object mode, schema rendered as a system message): 19
/// synthetic probes and 10 recorded requests; content at 4.5 bytes per token,
/// tool definitions at 3.2, no measurable fixed or tool-calling cost.
/// Recorded requests: −4.5% to +8.2% (default estimate: +14% to +47%).
const KIMI_K2_6_ESTIMATOR: HeuristicContextEstimator = DEFAULT
.with_messages
.with_tool_definitions
.with_request_tokens
.with_output_schema_in_prompt;
/// Kimi K3 (JSON Object mode): 21 synthetic probes and 10 recorded requests;
/// content at 4.5 bytes per token with twice Kimi K2.6's message framing.
/// Recorded requests: −4.7% to +7.4% (default estimate: +18% to +53%).
const KIMI_K3_ESTIMATOR: HeuristicContextEstimator = DEFAULT
.with_messages
.with_tool_definitions
.with_request_tokens
.with_output_schema_in_prompt;
/// Muse Spark 1.3: 25 synthetic probes and 39 recorded requests; content at
/// 4.4 bytes per token, tool definitions at 2.9, and a 420-token
/// tool-calling preamble. Muse counts the `json_schema` response format only
/// beside tools, which every Agentty request advertises. Recorded requests:
/// −6.9% to +6.9% (default estimate: +23% to +64%).
const MUSE_SPARK_1_3_ESTIMATOR: HeuristicContextEstimator = DEFAULT
.with_messages
.with_tool_definitions
.with_request_tokens
.with_output_schema_in_prompt;
/// Qwen3.8-Max (JSON Object mode): 24 synthetic probes and 39 recorded
/// requests; content at 4.2 bytes per token, tool definitions at 2.7, and a
/// 250-token tool-calling preamble. Recorded requests: −8.3% to +9.6%
/// (default estimate: +22% to +69%).
const QWEN3_8_MAX_ESTIMATOR: HeuristicContextEstimator = DEFAULT
.with_messages
.with_tool_definitions
.with_request_tokens
.with_output_schema_in_prompt;
/// Qwen-Plus (JSON Object mode): 25 synthetic probes and 39 recorded
/// requests; content at 4.2 bytes per token and tool definitions at 2.7.
/// Recorded requests: −7.9% to +10.9% (default estimate: +19% to +63%).
const QWEN_PLUS_ESTIMATOR: HeuristicContextEstimator = DEFAULT
.with_messages
.with_tool_definitions
.with_request_tokens
.with_output_schema_in_prompt;
/// Returns the declared context profile of `model`, or `None` when its
/// provider CLI manages context itself, the `ag-harness` provider catalog
/// declares it, as for the Qwen flash and ChatGPT-plan models, or, for the
/// OpenAI-compatible model, the environment declares it. Muse's contributor
/// tier serves the same model as Muse Spark 1.3 and shares its profile.
pub const