Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

docs(cli): note that the session cache rate is parent-loop only

thinhlpgc6be18ebcfcf
diff --git a/src-tauri/src/core/cli/tui.rs b/src-tauri/src/core/cli/tui.rs
index 2974b27ba..9c4a68c8d 100644
--- a/src-tauri/src/core/cli/tui.rs
+++ b/src-tauri/src/core/cli/tui.rs
@@ -2158,6 +2158,11 @@ struct App {
/// the tokens really were spent; they are dropped only when the conversation
/// they describe is gone ([`App::reset_session`]) or replaced wholesale
/// ([`load_thread`]).
+ ///
+ /// Parent-loop requests only: a child run has its own prefix and its own
+ /// conversation, so its prompts count towards its panel's context figure and
+ /// its spend towards `--output-format json` (which does fold children in),
+ /// never towards this rate. See [`App::apply_subagent_event`].
session_prompt_tokens: u64,
session_cached_tokens: u64,
session_cache_write_tokens: u64,
@@ -5568,6 +5573,12 @@ impl App {
panel.requests += 1;
}
}
+ // The child's own context high-water mark, and deliberately nothing
+ // else: its cache reads stay out of the `session_*` counters and so
+ // out of the header rate, which describes the parent conversation's
+ // prefix (a child has its own). `--output-format json` is the
+ // surface that folds child usage in, because that figure is a bill
+ // rather than a rate.
StreamEvent::TurnUsage { usage } => {
if let Some(panel) = self.subagents.iter_mut().find(|p| p.run_id == run_id) {
panel.prompt_tokens = usage.prompt_tokens.unwrap_or(panel.prompt_tokens);