Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

gateway: a ported Codex rollout reads the same through magpie as magpie's compaction item did

yetone19901812e766
diff --git a/internal/gateway/codex_portable_test.go b/internal/gateway/codex_portable_test.go
new file mode 100644
index 000000000..b17275531
--- /dev/null
+++ b/internal/gateway/codex_portable_test.go
@@ -0,0 +1,35 @@
+package gateway
+
+import (
+ "encoding/json"
+ "reflect"
+ "testing"
+
+ "github.com/yetone/magpie/internal/codexsummary"
+)
+
+// A rollout written portable (sessions.PortCodexRollouts) holds, in place
+// of magpie's compaction item, the message the gateway sends for it: what
+// reaches the model through magpie is the same either way, for a magpie
+// model and for Codex's own, natively compacted or not.
+func TestPortedCompactionReadsTheSame(t *testing.T) {
+ enc := codexsummary.Encrypted("Progress: done.\nNext: tests.")
+ msg, _ := codexsummary.Message(enc)
+ body := func(item any) []byte {
+ b, _ := json.Marshal(map[string]any{"model": "gpt-5.4", "input": []any{
+ userMessage("fix the build"), item, userMessage("go on")}})
+ return b
+ }
+ before := body(map[string]any{"type": "compaction", "id": "cmp_magpie_1", "encrypted_content": enc})
+ after := body(msg)
+ for _, c := range []struct{ magpieModel, native bool }{{true, false}, {true, true}, {false, false}} {
+ a, _ := codexInputAs(before, c.magpieModel, c.native)
+ b, _ := codexInputAs(after, c.magpieModel, c.native)
+ var x, y any
+ json.Unmarshal(a, &x)
+ json.Unmarshal(b, &y)
+ if !reflect.DeepEqual(x, y) {
+ t.Errorf("%+v: magpie's item sent as\n%s\nthe ported message as\n%s", c, a, b)
+ }
+ }
+}