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
//! Declared context profiles for the catalog models whose context Agentty
//! manages: Codex app-server compaction and native harness registrations.
//!
//! The `ag-harness` provider catalog declares the Kimi, Muse, and Claude
//! profiles, the first two fitted as below; Agentty declares the Qwen3.8-Max
//! and Qwen-Plus ones.
//!
//! 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;
/// 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;
/// 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 Kimi, Muse, Qwen flash, ChatGPT-plan, and Claude
/// models,
/// or, for the OpenAI-compatible model, the environment declares it.
pub const