3 Commits
Author SHA1 Message Date
unisong c590a74057 codex-history 0.1.2: a group or fallback try is filtered with the tried provider's rule (#525)
A request through a Magpie group or fallback names the group, so 0.1.1's
onRequest found no provider rule and sent old reasoning, ciphertext and item
IDs to members whose filter was on. onProvider now filters each provider try
with the tried provider's rule (`magpie:<ctx.provider.id>`, through aliases).
A direct provider/model request filtered in onRequest is marked in
ctx.state.historyFiltered and its tries pass it on. A try with no rule, a rule
off, another protocol, the compact path or history that can't move is
returned unchanged (onProvider can't reject). cases.json gains 10 synthetic
provider-try cases in the shared scripts/middleware.mjs format (no real data).

Run at the reviewed head c50f542 (on mote):
- `HOME=$(mktemp -d) bun test`: 3776 pass, 8 skip, 0 fail.
- `bun scripts/check.mjs`: exit 0.
- PR's tests against the 0.1.1 middleware: 8 fail (the group/fallback cases
  and the export check), 34 pass.
- Probes in magpie's own engine (moejs, origin/main 3bce283df,
  internal/middleware Run.Request + Run.Tried, not committed): a group with a
  filtered, an unfiltered, a rule-off member, a retry on the filtered one and
  a member with another include rule: each try filtered by its own rule, the
  retry byte-identical to the first, unfiltered tries byte-identical to the
  request. A direct request: filtered once in onRequest, its try, a retry and
  a fallback to another provider sent what onRequest left. ctx.state doesn't
  reach the next request. Red on 0.1.1 (group), red with the
  historyFiltered guard removed (fallback re-filtered) and red with
  onProvider setting the flag (retry unfiltered).
- PROVENANCE: the shipped files' sha256 match unisong/magpie-codex-history-filter
  at 43e0b5c, which is on its main.

Not tried: a real Magpie with real providers; a group whose members speak
different protocols.
2026-10-30 18:46:55 +08:00
unisong a73237c74c codex-history 0.1.1: historical web_search_call replayed as text after reasoning is filtered (#204)
Historical native `web_search_call` items become a labeled assistant text message (recorded status, action, queries and sources; no item id, no internal turn metadata) once the filter has removed the reasoning they depend on. Other native tools keep their ids; tool call/result pairs, unsafe-reference rejection and passthrough for providers without the rule are unchanged. Split out of #168 as asked in its review. codex-history 0.1.0 -> 0.1.1.

What was run at 61b6f0b (reviewer, bun 1.4.2, macOS):
- bun test packages/codex-history: 29 pass, 0 fail. node --test packages/codex-history/web-search.test.mjs: 6 pass. bun scripts/check.mjs codex-history: exit 0.
- Broken by hand: with the web_search_call branch disabled, 5 bun tests and 4 node tests go red.
- magpie (built from yetone/magpie main 85eef5d87) in a sandbox HOME, middleware added from the PR's package, a custom Responses provider `demo` pointing at a local fake, options {"providers":{"magpie:demo":{"historyFilter":true}}}, gateway on 127.0.0.1:18763 (moejs). A Codex-shaped request with reasoning + web_search_call + function_call pair: the fake received the search as the labeled assistant text, no rs_/ws_ ids, no PRIVATE_TURN, the call pair intact, store false. With main's 0.1.0 file swapped in, the fake received the bare web_search_call.
- Not tried: a real Codex session or real vendors.
2026-10-17 17:54:06 +08:00
unisong 7687314d07 codex-history: opt-in Codex Responses history filter middleware (#152)
An opt-in gateway middleware for Codex Responses history after a provider
or account switch. For a provider whose rule turns historyFilter on, it
drops old reasoning items and items typed encrypted_content, removes the
optional server id from message and tool items, and sets store false. It
keeps text, tool arguments, results and call_id pairing. It rejects
previous_response_id, conversation, item_reference, encrypted compaction
and /responses/compact with a message, instead of dropping them silently.
Every provider passes through unless configured. No network, file, env or
child-process access.

Run at the reviewed head 96881ead, merged with origin/main:
- bun test packages/codex-history: 22 pass, 0 fail.
- The same 22 cases.json cases through magpie's own engine (moejs, via
  internal/middleware Begin/Request in a throwaway test): 22 ran, all equal.
- Broke it by hand (reasoning items kept): bun 4 fail, moejs 4 BAD; restored.
- Whole repo: bun test 1606 pass, 0 fail; bun scripts/check.mjs exit 0.
2026-10-16 15:11:17 +08:00