Files
CLIProxyAPI/internal/runtime/executor/helps/codex_commentary_test.go
Luis Pater cc4b9949e7 feat(claude): add opt-in visible Codex commentary with preserved replay
- Add `client.claude.show-codex-commentary` config and propagate the request-scoped display policy through HTTP and WebSocket Codex executors.
- Mirror public Codex `commentary` messages into visible Claude text blocks alongside the `cpa:commentary:v1` thinking marker in streaming and non-streaming responses without altering genuine reasoning or token accounting.
- Deduplicate only the exact adjacent mirrored commentary text block during Claude-to-Codex request replay when enabled.

Closes: #7129
2026-10-31 10:04:12 +08:00

34 lines
1.2 KiB
Go

package helps
import (
"context"
"testing"
"github.com/router-for-me/CLIProxyAPI/v8/internal/config"
translatorcommon "github.com/router-for-me/CLIProxyAPI/v8/internal/translator/common"
)
func TestCodexCommentaryPolicyDefaultsAndSnapshots(t *testing.T) {
t.Setenv("CPA_VISIBLE_CODEX_COMMENTARY", "")
if translatorcommon.VisibleCodexCommentary(WithCodexCommentaryPolicy(nil, nil)) {
t.Fatal("commentary must remain hidden by default")
}
cfg := &config.Config{}
cfg.Client.Claude.ShowCodexCommentary = true
inFlight := WithCodexCommentaryPolicy(context.Background(), cfg)
cfg.Client.Claude.ShowCodexCommentary = false
if !translatorcommon.VisibleCodexCommentary(inFlight) {
t.Fatal("config reload changed an in-flight stream")
}
if translatorcommon.VisibleCodexCommentary(WithCodexCommentaryPolicy(context.Background(), cfg)) {
t.Fatal("new request did not use the changed policy")
}
}
func TestCodexCommentaryPolicyEnvironmentCompatibility(t *testing.T) {
t.Setenv("CPA_VISIBLE_CODEX_COMMENTARY", "1")
if !translatorcommon.VisibleCodexCommentary(WithCodexCommentaryPolicy(context.Background(), &config.Config{})) {
t.Fatal("legacy opt-in environment variable was ignored")
}
}