Skip to content

fix(providers): inject top-level instructions for openai-responses wire (#134)#160

Open
hqhq1025 wants to merge 1 commit intomainfrom
fix/openai-responses-instructions-134
Open

fix(providers): inject top-level instructions for openai-responses wire (#134)#160
hqhq1025 wants to merge 1 commit intomainfrom
fix/openai-responses-instructions-134

Conversation

@hqhq1025
Copy link
Copy Markdown
Collaborator

Summary

  • Strict OpenAI-Responses gateways (sub2api-style routers) return 400 when input[] carries a system/developer role without a matching top-level instructions field. pi-ai's plain openai-responses wire emits the former but not the latter.
  • Mirror the openai-codex-responses wire's strict behavior via pi-ai's onPayload hook: set params.instructions from the aggregated systemPrompt, and filter out role === "system" | "developer" entries from input[].
  • Only wired when model.api === "openai-responses" AND systemPrompt is non-empty. Other wires (anthropic-messages, openai-completions, openai-codex-responses) are untouched.

Fixes #134.

Four principles

  • Compatibility: green — no schema or IPC change; only the wire payload for openai-responses is adjusted; other wires unchanged.
  • Upgradeability: green — the filter/inject is local to complete(); if pi-ai later emits instructions natively we can delete the hook in one place.
  • No bloat: green — ~20 lines, no new deps, reuses existing toPiContext output (no helper refactor).
  • Elegance: green — contract mirrors how openai-codex-responses already behaves upstream.

Test plan

  • pnpm --filter @open-codesign/providers test -- --run (10 files, 134 tests, incl. 3 new cases: payload mutation, no-op when systemPrompt empty, no-op for anthropic wire)
  • pnpm typecheck (10/10 tasks successful)
  • pnpm lint (biome clean)
  • Manual: call an openai-responses gateway that requires instructions and confirm 200 with system prompt honored

@github-actions github-actions Bot added the area:providers packages/providers (pi-ai adapter, model calls) label Apr 22, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • No high-confidence issues found in added/modified lines.

Summary

  • Review mode: initial
  • No issues identified in the latest diff.
  • Residual risk/testing gap: behavior depends on pi-ai request payload shape for onPayload; repo tests cover unit-level mutation logic, but there is no in-repo integration test against a strict OpenAI-Responses gateway.

Testing

  • Not run (automation)

open-codesign Bot

…re (#134)

Strict OpenAI-Responses gateways reject requests that carry a
system/developer role inside input[] without a matching top-level
`instructions` field. pi-ai's plain `openai-responses` wire emits the
former but not the latter, so sub2api-style routers return 400.

Mirror the codex wire's strict behavior via the `onPayload` hook:
 - set params.instructions from the aggregated systemPrompt
 - filter out role === "system" | "developer" entries from input[]

Only wired when model.api === "openai-responses" AND systemPrompt is
non-empty. Other wires (anthropic-messages, openai-completions,
openai-codex-responses) are untouched.

Signed-off-by: hqhq1025 <1506751656@qq.com>
@hqhq1025 hqhq1025 force-pushed the fix/openai-responses-instructions-134 branch from a7f8a5f to 3fdebd0 Compare April 22, 2026 14:19
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • No high-confidence issues found in added/modified lines.

Summary

  • Review mode: follow-up after new commits
  • No issues identified in the latest diff.
  • Not found in repo/docs: docs/VISION.md and docs/PRINCIPLES.md in this checkout; review used available repo context plus full PR diff.
  • Residual risk/testing gap: behavior relies on pi-ai payload shape for onPayload; current coverage is unit-level and does not include an integration test against a strict OpenAI-Responses gateway.

Testing

  • Not run (automation)

open-codesign Bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers packages/providers (pi-ai adapter, model calls)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(desktop): macOS generation fails with Instructions are required and no visible output

1 participant