Skip to content

fix(ci): keep gpt-5.5 for issue triage by inlining encrypted reasoning - #942

Merged
dcramer merged 5 commits into
mainfrom
cursor/fix-flue-triage-pi-ai-store-ed2f
May 8, 2026
Merged

dcramer merged 5 commits into
mainfrom
cursor/fix-flue-triage-pi-ai-store-ed2f

Conversation

@dcramer

@dcramer dcramer commented May 8, 2026 •

Copy link
Copy Markdown
Member

Problem

The Flue issue-triage workflow (failing run) 404s on the first multi-turn round-trip after a tool call:

[flue] Error: [flue] skill("issue-triage") failed: 404 Item with id 'rs_...' not found.
Items are not persisted when `store` is set to false.

Same root cause every framework keeps tripping on (vercel/ai#7543, openai/openai-agents-python#2265, openclaw/openclaw#16803, earendil-works/pi#3369): @mariozechner/pi-ai — the LLM client Flue uses internally — hardcodes store: false on the OpenAI Responses API and then replays rs_* reasoning IDs from the previous turn. Without server-side persistence the IDs don't resolve and OpenAI 404s.

Why we don't downgrade to a non-reasoning model

The previous revision worked around this by switching the default to openai/gpt-4.1. That bypasses the bug (gpt-4.1 is reasoning: false in pi-ai's registry, so the entire reasoning code path is skipped), but it also throws away gpt-5's reasoning quality on a hook whose whole job is judgment calls (duplicate detection, severity, validity). We want to stay on gpt-5.

Why we don't patch pi-ai or fork it

Fix

OpenAI's documented escape hatch for store: false + reasoning is include: ["reasoning.encrypted_content"]. With it, OpenAI returns the full encrypted reasoning blob inline; pi-ai already serializes that blob into thinkingSignature and ships it back on replay (convertResponsesMessages in openai-responses-shared.js). No store=true, no provider-side retention, no patch.

@flue/sdk 0.3.11 has no public knob to set this, but the underlying pi-agent-core Agent does: it forwards an onPayload hook into streamFn, and pi-ai's openai-responses provider invokes options?.onPayload?.(params, model) after building the request. So we reach into the Session's harness once, install a tiny onPayload, and let pi-ai do the rest.

The hook is a no-op for non-reasoning models and for any provider that isn't OpenAI Responses / Azure OpenAI Responses, so flipping FLUE_TRIAGE_MODEL to a Claude or non-reasoning model still works unchanged. We can drop the hook the moment Flue ships #69 or pi-ai stops hardcoding store: false.

Files

  • .flue/agents/issue-triage.ts — install enableEncryptedReasoning(session) and switch the default back to openai/gpt-5.
  • docs/flue-hooks.md — document the hook, the new default, and the upstream tracking issues.

Verification

  • pnpm install — node_modules/.pnpm/@[email protected]_…/dist/providers/openai-responses.js is back to unmodified upstream store: false; no patches/ directory.
  • pnpm run tsc && pnpm run lint && pnpm run test — all green.
  • pnpm exec flue build --target node — agent compiles; dist/server.mjs contains the bundled hook (enableEncryptedReasoning, harness.onPayload, the literal "reasoning.encrypted_content").
  • Reconstructed the harness wiring with pi-agent-core's Agent + pi-ai's getModel. Confirmed:
    1. The hook adds reasoning.encrypted_content to a real getModel("openai", "gpt-5") payload.
    2. The same hook leaves getModel("openai", "gpt-4.1") payloads untouched (no include field).
    3. pi-agent-core.createLoopConfig forwards harness.onPayload into the streamFn options object — i.e. exactly the path pi-ai's openai-responses provider invokes after buildParams.

End-to-end execution of the triage workflow itself still requires OPENAI_API_KEY / GH_TOKEN, which aren't available in this environment. Once merged, re-running on issue #941 (or any new issue) will exercise the gpt-5 path with the encrypted reasoning replay.

Slack Thread

Open in Web Open in Cursor 

The Flue issue triage agent fails on multi-turn conversations with
gpt-5 because @mariozechner/pi-ai hardcodes `store: false` in its
OpenAI Responses provider. When tools are called, gpt-5 emits
reasoning items with rs_* IDs that are replayed on the next turn, but
OpenAI rejects them because no item was persisted server-side.

  Error: 404 Item with id 'rs_...' not found.
  Items are not persisted when `store` is set to false.

Patch the bundled pi-ai provider to send `store: true`, matching the
OpenAI Responses API default and unblocking the triage workflow until
the upstream fix lands.

Refs: earendil-works/pi#3369

Co-Authored-By: Cursor Agent <[email protected]>
…ue triage"

This reverts the pi-ai pnpm patch from fb0bd97. Patching a hardcoded
upstream value to its inverse is too blunt a hammer for what is, at
its core, a model-selection problem in the triage agent. Drop the
patch and pin to a non-reasoning model in the next commit instead.

Co-Authored-By: Cursor Agent <[email protected]>
The Flue issue-triage workflow fails on every multi-turn call:

  [flue] Error: skill("issue-triage") failed: 404 Item with id
  'rs_...' not found. Items are not persisted when `store` is set
  to false.

Root cause is upstream and not patchable from here:

- Flue 0.3.11 (latest) drives every chat through @mariozechner/pi-ai
  with `thinkingLevel: "off"` hardcoded, no public option to override.
- pi-ai 0.73.1 is the last version under that npm scope (the project
  migrated to @earendil-works/pi-ai 0.74.0 on 2026-05-07, which Flue
  does not yet depend on).
- pi-ai's OpenAI Responses provider hardcodes `store: false` and,
  for reasoning models, only requests `include:
  ["reasoning.encrypted_content"]` when a reasoning effort is passed.
  With Flue passing none, gpt-5 emits `rs_*` items that have neither
  server-side persistence nor inline encrypted payloads, and the next
  turn 404s.
- The fix that would let us keep gpt-5 (Flue exposing `reasoning` /
  `thinkingLevel` per call, withastro/flue#69) was merged into Flue
  main on 2026-05-08 but is not yet released. The pi-ai-side fix
  (earendil-works/pi#1504, defaulting `store: true`) was auto-closed
  and never merged.

Until one of those lands, drop the default to `openai/gpt-4.1` — a
non-reasoning model on the same OpenAI Responses path that never
emits `rs_*` items, so multi-turn replay works without any patch.
Operators can still override via the `FLUE_TRIAGE_MODEL` repo
variable; once Flue picks up `reasoning` plumbing we can flip the
default back to `openai/gpt-5` and pass `reasoning: "minimal"`.

Refs:
- earendil-works/pi#3369
- earendil-works/pi#1504
- withastro/flue#69

Co-Authored-By: Cursor Agent <[email protected]>
@cursor cursor Bot changed the title fix(ci): patch pi-ai to enable OpenAI Responses store for issue triage fix(ci): default issue triage to a non-reasoning model May 8, 2026
pi-ai (the LLM client Flue uses) hardcodes store: false on the OpenAI
Responses API. With reasoning models (gpt-5, o-series, ...), every
multi-turn call 404s because pi-ai replays the rs_* reasoning IDs from
the previous turn and OpenAI cannot look them up when nothing was
persisted.

The supported escape hatch is to ask OpenAI to inline the encrypted
reasoning blob via include: ["reasoning.encrypted_content"]. pi-ai's
convertResponsesMessages then ships that blob back on replay, so no
server-side persistence is needed.

@flue/sdk 0.3.11 doesn't expose a reasoning/thinkingLevel knob, so we
reach into the Session's pi-agent-core harness and install pi-ai's
existing onPayload hook to add the include flag for any
openai-responses / azure-openai-responses reasoning model. The hook is
a no-op for non-reasoning models and other providers.

This unblocks gpt-5 as the default triage model. FLUE_TRIAGE_MODEL
still overrides if we want to pin a different model.

Verified by reconstructing the harness wiring (Agent + getModel) and
asserting:
  1. The hook adds reasoning.encrypted_content to gpt-5 payloads.
  2. Non-reasoning models (gpt-4.1) are left untouched.
  3. pi-agent-core forwards onPayload into streamFn, which is the same
     code path pi-ai's openai-responses provider invokes after building
     the request.

Refs: earendil-works/pi#3369, earendil-works/pi#1504, withastro/flue#69.

Co-Authored-By: Cursor Agent <[email protected]>
@cursor cursor Bot changed the title fix(ci): default issue triage to a non-reasoning model fix(ci): keep gpt-5 for issue triage by inlining encrypted reasoning May 8, 2026
The encrypted reasoning hook already handles gpt-5.5 (same
openai-responses API with reasoning: true), so no other changes needed.
@sentry-junior sentry-junior Bot changed the title fix(ci): keep gpt-5 for issue triage by inlining encrypted reasoning fix(ci): keep gpt-5.5 for issue triage by inlining encrypted reasoning May 8, 2026
@dcramer
dcramer marked this pull request as ready for review May 8, 2026 21:05
@dcramer
dcramer merged commit 6f8a04f into main May 8, 2026
13 checks passed
@dcramer
dcramer deleted the cursor/fix-flue-triage-pi-ai-store-ed2f branch May 8, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants