Files
magpie/internal/gateway/testdata/codex-26.1007-compaction.json
T
yetone 299498dec1 gateway: a compaction magpie summarises itself tells the provider it is a local one, not Codex's remote compaction_v2 (#2352, yhxwyzm; #1171, tcxp001)
Codex Desktop 26.1007 marks a compaction for a provider named "OpenAI"
with a compaction_trigger item and turn metadata saying
compaction.implementation "responses_compaction_v2", in both
client_metadata["x-codex-turn-metadata"] and the X-Codex-Turn-Metadata
header. When 原生压缩 is off, magpie replaces the trigger with its own
summary prompt and sends tools [], but it forwarded the metadata
unchanged. The request then said "remote compaction" and carried no
trigger, a shape Codex never sends. Codex 0.162.1, captured in a sandbox
against a provider not named OpenAI, says "responses" for the summary it
asks for; under the name OpenAI it sends the trigger with
"responses_compaction_v2". Neither the #292 test nor the #1171 test
carried client_metadata, so neither saw this.

codexInputAs (both the ChatGPT-backend path and /v1/responses) now sets
implementation to "responses" in the body's turn metadata, and
codexCompact does the same in the header. Every other byte of the
metadata is unchanged, including mcp_attribution and
guardian_credits_requested. With native compaction on, the trigger and
its metadata still go as Codex sent them.

The fixture testdata/codex-26.1007-compaction.json uses the reporter's
own bytes from the Routing page bodies attached to #2352 (on.txt and
off.txt): four history items, among them an mcp__fastctx call with its
list output, and the client_metadata as sent. The fake upstream refuses
with the relay's words when a request says responses_compaction_v2 and
has no trigger.

Not verified against Anyrouter itself. The reporter says the error text
is the same with native compaction on, and there magpie sends the
trigger as an OpenAI-named Codex would; that path is unchanged. If the
relay doesn't take remote compaction at all, this commit doesn't help
there.

Run (worktree on origin/main 35aa50cfb, -p 1 -tags nogui, sandbox HOME):
- go test ./internal/gateway -run 'TestLocalCompaction|TestNativeCompaction|Native|Compact|TestSearchHistory|TestCodexOpenAIFields|TestCodex|ClientMetadata|Bare': ok (308 tests match the pattern)
- gofmt -l: clean; go vet for darwin, linux and windows: clean
Broken by hand: I turned off the codexInputAs rewrite, and then
separately the header rewrite in codexCompact. Each time
TestLocalCompactionSaysLocal went red on both paths with
400 "Fake: invalid codex request".

Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00

2 lines
9.1 KiB
JSON

{"model":"fake/m1","stream":true,"input":[{"type":"message","id":"msg_01a13df6-ad6b-7201-be79-21b2cb918b0d","role":"user","content":[{"type":"input_text","text":"对当前的接口做一次全测试\n"}],"internal_chat_message_metadata_passthrough":{"turn_id":"01a13df6-a6ad-7782-b5eb-1e8759986f09","create_time":1792040938.8599522,"content_item_kinds":["user.text"]}},{"type":"message","id":"msg_18de9bbf4beb61c400000127","role":"assistant","content":[{"type":"output_text","text":"我会先梳理项目里的接口、鉴权和现有测试,再运行能在本地安全执行的测试,汇总失败项、风险和未覆盖部分。\n"}],"internal_chat_message_metadata_passthrough":{"turn_id":"01a13df6-a6ad-7782-b5eb-1e8759986f09","content_item_kinds":["unknown"]}},{"type":"function_call","id":"fc_18de9bbf8d32bf8800000128","name":"inspect_local_file","namespace":"mcp__fastctx","arguments":"{\"file_path\":\"C:/Users/10851/.agents/skills/everything-search/SKILL.md\",\"limit\":260}","encrypted_function_args":[],"call_id":"call_0xsoGrJ6UxCP0f5bSGlP7hrG","internal_chat_message_metadata_passthrough":{"turn_id":"01a13df6-a6ad-7782-b5eb-1e8759986f09"}},{"type":"function_call_output","id":"fco_01a13df6-d8d1-7f42-b211-2bb234090e6f","call_id":"call_0xsoGrJ6UxCP0f5bSGlP7hrG","output":[{"type":"input_text","text":"Wall time: 0.0246 seconds\nOutput:"},{"type":"input_text","text":"1\t---\n2\tname: everything-search\n3\tdescription: Search files and folders instantly across Windows drives or within specific project paths using Everything (HTTP REST API or es.exe CLI). Supports sandboxed agents (Docker, WSL, DevContainers) and native desktop environments with automatic dual-mode fallback.\n4\t---\n5\t\n6\t# Everything Search (Dual-Mode: HTTP REST API & CLI)\n7\t\n8\tUltra-fast, index-powered local file search using Voidtools Everything.\n9\tSupports both **HTTP REST API mode** (essential for sandboxed/containerized agents like Docker, WSL, DevContainers) and **native CLI mode** (`es.exe` Win32 IPC) with automatic fallback.\n10\t\n11\t---\n12\t\n13\t## Why Dual-Mode? (Solving Sandboxed Agent IPC Issues)\n14\t\n15\tWhen an AI agent runs inside a **sandbox**, **Docker container**, **WSL2**, or a **Session 0 background service**, calling `es.exe` directly often fails with:\n16\t`Error 8: Everything IPC window not found. Please make sure Everything is running.`\n17\t\n18\t**Root Cause**: Windows enforces User Interface Privilege Isolation (UIPI) and Session Isolation. Sandboxed processes and non-interactive sessions cannot send Win32 `WM_COPYDATA` window messages to the host desktop session.\n19\t\n20\t**The Solution**:\n21\tEverything provides a high-performance built-in **HTTP REST API**. Network calls (TCP) bypass Win32 UIPI/session isolation entirely:\n22\t- **Sandboxed Agent / Container** ➡️ HTTP Request (`http://host.docker.internal:8080`) ➡️ Host Everything Index (Instant Results!)\n23\t- **Native Desktop Session** ➡️ Automatic fallback to `es.exe` CLI if HTTP is disabled.\n24\t\n25\t---\n26\t\n27\t## When to Use This Skill\n28\t\n29\tUse this skill whenever you need to:\n30\t- Locate files or directories instantly across local drives or inside a project directory\n31\t- Search files in sandboxed environments (Docker, WSL, restricted agents) without IPC errors\n32\t- Filter by name pattern, extension (`ext:ts;tsx`), size (`size:>100MB`), or date modified (`dm:today`)\n33\t- Output structured JSON for automated pipelines without token-costly directory walks\n34\t\n35\t---\n36\t\n37\t## Quick Start: Python Dual-Mode Helper (Recommended)\n38\t\n39\tThe skill includes `scripts/everything_search.py`, which uses **only Python standard libraries** (zero external dependencies like `requests`).\n40\t\n41\t```bash\n42\t# Auto mode: Attempts HTTP on port 8080 first; falls back to es.exe CLI automatically\n43\tpython scripts/everything_search.py \"package.json\" -n 20\n44\t\n45\t# Structured JSON output\n46\tpython scripts/everything_search.py \"ext:py model\" -n 10 --json\n47\t\n48\t# Restrict search to a specific directory\n49\tpython scripts/everything_search.py \"main.go\" -p \"C:\\MyProject\" -n 5\n50\t\n51\t# Explicitly force HTTP REST mode\n52\tpython scripts/everything_search.py \"exact:Dockerfile\" --mode http\n53\t\n54\t# Specify custom host/port (e.g. from Docker container to host)\n55\tpython scripts/everything_search.py \"*.json\" --url \"http://host.docker.internal:8080\" -n 10\n56\t```\n57\t\n58\t---\n59\t\n60\t## Sandboxed & Container Environment Configuration\n61\t\n62\t### 1. Enable HTTP Server on Windows Host (One-time Setup)\n63\tIn Everything on the host machine:\n64\t1. Open Everything -> **Tools** (工具) -> **Options** (选项).\n65\t2. Click **HTTP Server** (HTTP 服务器) in the left menu.\n66\t3. Check **Enable HTTP Server** (启用 HTTP 服务器), set Port to `8080`, and click OK.\n67\t*(Optional: run `scripts/enable_http.ps1` to configure automatically).*\n68\t\n69\t### 2. Connect from Docker Container\n70\tRun your Docker container with host access:\n71\t```bash\n72\tdocker run -e EVERYTHING_HTTP_URL=http://host.docker.internal:8080 --add-host host.docker.internal:host-gateway ...\n73\t```\n74\tInside the container:\n75\t```python\n76\tpython scripts/everything_search.py \"ext:rs\" -n 10 --json\n77\t```\n78\t\n79\t### 3. Connect from WSL2\n80\tInside WSL, resolve the Windows host IP:\n81\t```bash\n82\texport EVERYTHING_HTTP_URL=\"http://$(ip route show | awk '/default/ {print $3}'):8080\"\n83\tpython3 scripts/everything_search.py \"ext:md\" -n 10\n84\t```\n85\t\n86\t---\n87\t\n88\t## Direct CLI Usage (`es.exe` for Native Desktop Sessions)\n89\t\n90\tWhen running directly in a native Windows user desktop session:\n91\t\n92\t```powershell\n93\t# Basic search (ALWAYS specify -n to prevent flooding LLM context)\n94\tes.exe -n 20 \"settings.json\"\n95\t\n96\t# Search inside project folder\n97\tes.exe -path \"C:\\my-repo\" -n 20 \"index.ts\"\n98\t\n99\t# Files only (/a-d) or Folders only (/ad)\n100\tes.exe /a-d -n 15 \"ext:tsx component\"\n101\tes.exe /ad -n 10 \"node_modules\"\n102\t\n103\t# Sort by date modified (newest first)\n104\tes.exe -sort-date-modified-descending -n 10 \"ext:log dm:today\"\n105\t```\n106\t\n107\t---\n108\t\n109\t## Everything Search Syntax Cheatsheet\n110\t\n111\t| Filter | Syntax | Example |\n112\t|---|---|---|\n113\t| Multiple extensions | `ext:<ext1;ext2>` | `ext:md;txt;json` |\n114\t| File size | `size:>100MB` or `size:1MB..10MB` | `size:>500MB /a-d` |\n115\t| Date modified | `dm:<time>` | `dm:today`, `dm:last7days`, `dm:2025` |\n116\t| Exact match | `exact:<name>` | `exact:Dockerfile` |\n117\t| Logical AND | `space` | `auth controller ext:go` |\n118\t| Logical OR | `|` (with spaces) | `*.jpg | *.png` |\n119\t| Logical NOT | `!` | `*.ts !*.test.ts` |\n120\t| Regex search | `-r` flag | `es.exe -r \"src\\\\api\\\\.*\\.go$\"` |\n121\t\n122\t---\n123\t\n124\t## Environment Variables\n125\t\n126\t| Variable | Default | Purpose |\n127\t|---|---|---|\n128\t| `EVERYTHING_HTTP_URL` | `http://127.0.0.1:8080` | URL of Everything HTTP service |\n129\t| `EVERYTHING_HTTP_USER` | `\"\"` | Optional Basic Auth username |\n130\t| `EVERYTHING_HTTP_PASS` | `\"\"` | Optional Basic Auth password |\n131\t\n\n(Complete: reached end of file; lines 1-131 of 131 shown.)"}],"internal_chat_message_metadata_passthrough":{"turn_id":"01a13df6-a6ad-7782-b5eb-1e8759986f09","create_time":1792040949.9696774}},{"type":"compaction_trigger"}],"tools":[],"store":false,"include":["reasoning.encrypted_content"],"client_metadata":{"x-codex-installation-id":"c32cce85-81d0-41b7-9510-ffefdca8a149","x-codex-turn-metadata":"{\"installation_id\":\"c32cce85-81d0-41b7-9510-ffefdca8a149\",\"session_id\":\"01a13df6-856b-77a2-b2b1-b572d352bfc4\",\"thread_id\":\"01a13df6-856b-77a2-b2b1-b572d352bfc4\",\"agent_name\":\"/root\",\"turn_id\":\"01a13e4d-5f2b-7353-8a25-7705b40e62de\",\"window_id\":\"01a13df6-856b-77a2-b2b1-b572d352bfc4:0\",\"window_number\":0,\"context_window_id\":\"01a13df6-8571-7fa1-8d9d-2d3031f4f3e2\",\"request_kind\":\"compaction\",\"root_turn_id\":\"01a13e4d-5f2b-7353-8a25-7705b40e62de\",\"thread_source\":\"user\",\"turn_trigger\":\"composer\",\"sandbox\":\"none\",\"sandbox_mode\":\"danger-full-access\",\"auto_review_enabled\":false,\"node_repl_auto_review_required\":false,\"node_repl_disabled\":false,\"turn_started_at_unix_ms\":1792046620563,\"analytics_enabled\":true,\"compaction\":{\"trigger\":\"auto\",\"reason\":\"context_limit\",\"implementation\":\"responses_compaction_v2\",\"phase\":\"pre_turn\",\"strategy\":\"memento\"},\"client_type\":\"desktop_app\",\"source\":\"codex\",\"workspace_kind\":\"project\"}","thread_id":"01a13df6-856b-77a2-b2b1-b572d352bfc4","session_id":"01a13df6-856b-77a2-b2b1-b572d352bfc4","turn_id":"01a13e4d-5f2b-7353-8a25-7705b40e62de","x-codex-window-id":"01a13df6-856b-77a2-b2b1-b572d352bfc4:0","mcp_attribution":"{\"status\":\"complete\",\"sources\":[{\"server_name\":\"fastctx\",\"tool_name\":\"inspect_local_file\",\"first_turn_id\":\"01a13df6-a6ad-7782-b5eb-1e8759986f09\"},{\"plugin_id\":\"codex-app-tools@openai-bundled\",\"server_name\":\"codex_app\",\"tool_name\":\"open_in_codex\",\"first_turn_id\":\"01a13e0b-bb8c-7e33-b0f5-8250a7725d14\"}]}","guardian_credits_requested":"true","root_turn_id":"01a13e4d-5f2b-7353-8a25-7705b40e62de"}}