chore(models): update default client version and user agent, revise GPT-5.5 configurations

- Bumped the `defaultClientVersion` and `defaultCodexUserAgent` to `0.144.0`.
- Replaced GPT-5.6 Sol with GPT-5.5 in model registry, adjusting metadata including context window length and reasoning levels.
- Updated `usage_helpers` to include `cache_write_tokens` logic for input token details.
This commit is contained in:
Luis Pater
2026-07-10 01:54:37 +08:00
parent f21beb05b5
commit b4c594050e
4 changed files with 159 additions and 137 deletions
+2 -2
View File
@@ -42,8 +42,8 @@ import (
const (
codexModelsBaseURL = "https://chatgpt.com/backend-api/codex"
codexModelsPath = "/models"
defaultClientVersion = "0.133.0"
defaultCodexUserAgent = "codex_cli_rs/0.133.0 (Mac OS 26.3.1; arm64) iTerm.app/3.6.9"
defaultClientVersion = "0.144.0"
defaultCodexUserAgent = "codex_cli_rs/0.144.0 (Mac OS 26.3.1; arm64) iTerm.app/3.6.9"
defaultCodexOriginator = "codex_cli_rs"
accessTokenRefreshLeeway = 30 * time.Second
)
File diff suppressed because one or more lines are too long
@@ -514,6 +514,7 @@ func hasOpenAIStyleUsageTokenFields(usageNode gjson.Result) bool {
usageNode.Get("total_tokens").Exists() ||
usageNode.Get("prompt_tokens_details.cached_tokens").Exists() ||
usageNode.Get("input_tokens_details.cached_tokens").Exists() ||
usageNode.Get("input_tokens_details.cache_write_tokens").Exists() ||
usageNode.Get("completion_tokens_details.reasoning_tokens").Exists() ||
usageNode.Get("output_tokens_details.reasoning_tokens").Exists()
}
@@ -539,6 +540,9 @@ func parseOpenAIStyleUsageNode(usageNode gjson.Result) usage.Detail {
if cached.Exists() {
detail.CachedTokens = cached.Int()
}
if cacheWrite := usageNode.Get("input_tokens_details.cache_write_tokens"); cacheWrite.Exists() {
detail.CacheCreationTokens = cacheWrite.Int()
}
reasoning := usageNode.Get("completion_tokens_details.reasoning_tokens")
if !reasoning.Exists() {
reasoning = usageNode.Get("output_tokens_details.reasoning_tokens")
@@ -51,6 +51,29 @@ func TestParseOpenAIUsageResponses(t *testing.T) {
}
}
func TestParseCodexUsageIncludesCacheWriteTokens(t *testing.T) {
data := []byte(`{"response":{"usage":{"input_tokens":100,"output_tokens":20,"total_tokens":120,"input_tokens_details":{"cached_tokens":30,"cache_write_tokens":40}}}}`)
detail, ok := ParseCodexUsage(data)
if !ok {
t.Fatal("ParseCodexUsage() ok = false, want true")
}
if detail.InputTokens != 100 {
t.Fatalf("input tokens = %d, want 100", detail.InputTokens)
}
if detail.OutputTokens != 20 {
t.Fatalf("output tokens = %d, want 20", detail.OutputTokens)
}
if detail.CachedTokens != 30 {
t.Fatalf("cached tokens = %d, want 30", detail.CachedTokens)
}
if detail.CacheCreationTokens != 40 {
t.Fatalf("cache creation tokens = %d, want 40", detail.CacheCreationTokens)
}
if detail.TotalTokens != 120 {
t.Fatalf("total tokens = %d, want 120", detail.TotalTokens)
}
}
func TestParseOpenAIUsageIgnoresNullUsage(t *testing.T) {
data := []byte(`{"usage":null}`)
detail := ParseOpenAIUsage(data)