Files
CLIProxyAPI/internal/runtime/executor/helps/codex_commentary.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

19 lines
639 B
Go

package helps
import (
"context"
"github.com/router-for-me/CLIProxyAPI/v8/internal/config"
translatorcommon "github.com/router-for-me/CLIProxyAPI/v8/internal/translator/common"
)
// WithCodexCommentaryPolicy keeps an in-flight stream's policy stable across
// config reloads. It changes protocol display/replay only, not the payload rules.
func WithCodexCommentaryPolicy(ctx context.Context, cfg *config.Config) context.Context {
enabled := translatorcommon.VisibleCodexCommentary(ctx)
if cfg != nil && cfg.Client.Claude.ShowCodexCommentary {
enabled = true
}
return translatorcommon.WithVisibleCodexCommentary(ctx, enabled)
}