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(agent): note that the cache counters distinguish null from zero

thinhlpg4e703dea9612
diff --git a/docs/src/pages/docs/agent/cli.mdx b/docs/src/pages/docs/agent/cli.mdx
index 40a93273e..38ce49bf6 100644
--- a/docs/src/pages/docs/agent/cli.mdx
+++ b/docs/src/pages/docs/agent/cli.mdx
@@ -124,7 +124,13 @@ jan cli agent run --output-format json "review auth.rs" | jq -r .result
"model": "tokamak-1-preview",
"num_turns": 3,
"duration_ms": 48213,
- "usage": { "prompt_tokens": 9011, "completion_tokens": 655, "total_tokens": 9666 }
+ "usage": {
+ "prompt_tokens": 9011,
+ "completion_tokens": 655,
+ "total_tokens": 9666,
+ "cached_tokens": 8123,
+ "cache_write_tokens": null
+ }
}
```
@@ -154,6 +160,12 @@ had said before it broke as `result`:
| `session_id` | Short session id for `--resume`. `null` when the run failed before producing one |
| `num_turns` | Agent turns taken. Subagent turns are not counted |
| `usage` | Summed over every request the run made, subagents included |
+| `usage.cached_tokens` | Prompt tokens the provider served from its cache. `null` when the route reported no cache usage at all, `0` when it reported a zero read |
+| `usage.cache_write_tokens` | Prompt tokens written into the provider's cache. `null` when the route reports no write count |
+
+`null` and `0` are different answers: a route that reports no cache fields is not a cold cache, and a
+route that reports a zero read is - the prefix was written every turn and never reused. Piped
+consumers should branch on the difference rather than coalescing with `0`.
The process exit code is unchanged: `0` on success, `1` on failure.