pluo's Usage view showed Codex calls of kind composer_predictions at
133k-231k tokens each with no cache read: ChatGPT.app's Codex guesses the
user's next message with a hidden turn on a fork of the thread, on the
thread's own model, reading the whole conversation again each time. It
asks only when the thread's provider is "openai", so through Codex's own
ChatGPT sign-in (and a custom table pointed at magpie). The app's bundle
(fge) asks for {suggestion: string|null} and uses b.suggestion||null.
What changed:
- settings.CodexPredictions: "" as Codex sends it, "off", or a model id
(provider/model, group/<id>); anything else is refused on load.
- gateway: codexPredictionsTo + codexPrediction, wired beside the
descriptions at both entrypoints (gateway.go and codex_backend.go).
Off answers {"suggestion":null} from magpie and sends nothing (the
title Off path made generic as sentNowhere). A model's answer goes back
only as the object Codex asked for (predictionJSON: think tags and code
fences stripped, suggestion trimmed, blank = null). Plain text is never
taken as a suggestion, since Codex would put it in the user's composer
as their next message; it gives null and is recorded as a failure
("prediction: ...").
- usage: purpose "Prediction" for composer_predictions (purposes.js
regenerated).
- gui: POST /api/settings/codex-predictions, kept by the general save;
Settings › General row "Codex composer predictions" (Codex's own / Off /
magpie's models, the app's picker), hidden in gateway mode; Routing's
story for the kind says Codex's own switch (Settings › General › Show
predictions) and magpie's. i18n in zh, zh-TW, ja, de.
- docs: gateway-routing.md's Codex section, reference.md's gateway-mode
list. site/ docs left for the owner.
What was run:
- go test -tags nogui ./internal/gateway/ (full, -timeout 40m),
./internal/gui/ ./internal/settings/ ./internal/usage/: pass.
New: TestCodexPredictionsSetting (default to ChatGPT, off sent nowhere,
model routed, plain turn untouched, ledger kinds), TestNoPrediction,
TestCodexPredictionOnMagpie (/v1/responses and the backend path),
TestPredictionJSON; gui TestCodexPredictionsSetting.
- Broken by hand, each went red: backend wiring removed; plain text
accepted as a suggestion; the general save not keeping the setting;
the Routing story's kind check.
- Playwright codex-predictions.test.cjs: chromium + webkit, 1100 and 420
wide, en/zh/zh-TW/ja/de (20 pass). routing-kind (with the new kind),
codex-descriptions, codex-titles, i18n-keys, gateway-mode,
purpose-filter, routing-purpose-state, settings-general,
settings-sections, settings-search: pass.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows.
Not tried: the real ChatGPT.app's predictions against magpie (the
feature is gated server-side by /wham/predictions/config and isn't on for
the owner's account); the reply shape is from the app's bundle.
52 lines
1.7 KiB
Go
52 lines
1.7 KiB
Go
package usage
|
|
|
|
import "maps"
|
|
|
|
//go:generate go run ../gui/genpurposes -out ../gui/assets/purposes.js
|
|
|
|
// PurposeKind is the shared filtering key and untranslated display name of a kind.
|
|
type PurposeKind struct {
|
|
Purpose string `json:"purpose"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
var purposeKinds = func() map[string]PurposeKind {
|
|
out := map[string]PurposeKind{}
|
|
add := func(name string, kinds ...string) {
|
|
for _, kind := range kinds {
|
|
out[kind] = PurposeKind{"kind:" + kinds[0], name}
|
|
}
|
|
}
|
|
add("Approval check", "guardian", "auto_review", "guardian_review")
|
|
add("Review", "review")
|
|
add("Compaction", "compact")
|
|
add("Memory", "memory_consolidation", "memgen", "memory")
|
|
add("Title", "thread_title", "thread_title_reconsideration", "title_generation", "title")
|
|
add("Description", "thread_description")
|
|
add("Prediction", "composer_predictions")
|
|
add("Subagent", "collab_spawn", "thread_spawn", "agent_job")
|
|
add("Luna Reserve", "luna_reserve")
|
|
add("Suggestions", "ambient_suggestions", "ambient_suggestion_safety")
|
|
add("Web search", "web_search")
|
|
add("Image description", "vision")
|
|
add("Routing classifier", "routing")
|
|
return out
|
|
}()
|
|
|
|
// PurposeKinds returns a copy of the catalog used to generate the UI's catalog.
|
|
// Add aliases here, then run go generate ./internal/usage from the repo root.
|
|
func PurposeKinds() map[string]PurposeKind { return maps.Clone(purposeKinds) }
|
|
|
|
// PurposeOf groups the agent's equivalent call-kind spellings for filtering.
|
|
// The recorded Kind stays untouched. Prefixing nonempty kinds keeps future
|
|
// names distinct from the unmarked bucket (which is not necessarily a chat).
|
|
func PurposeOf(kind string) string {
|
|
if kind == "" {
|
|
return "unmarked"
|
|
}
|
|
if p, ok := purposeKinds[kind]; ok {
|
|
return p.Purpose
|
|
}
|
|
return "kind:" + kind
|
|
}
|