Skip to content

openapi: response fidelity — per-status schemas, headers, readOnly/writeOnly filtering - #355

Closed
RhysSullivan wants to merge 1 commit into
rs/openapi-url-templatefrom
rs/openapi-response-fidelity
Closed

RhysSullivan wants to merge 1 commit into
rs/openapi-url-templatefrom
rs/openapi-response-fidelity

Conversation

@RhysSullivan

@RhysSullivan RhysSullivan commented Apr 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Extracts the full { [status]: OperationResponse } map per operation instead of picking a single 2xx schema. Existing outputSchema is kept as the "preferred single schema" used in LLM tool definitions (first 2xx with a body, default fallback).
  • Lifts documented response headers (with their schemas + descriptions) into OperationResponse.headers.
  • Adds a readOnly / writeOnly schema filter: request-direction schemas have readOnly fields (and matching required entries) stripped; response-direction schemas have writeOnly stripped.
  • invoke() now records matchedResponseStatus on the InvocationResult by walking the response map: exact status → NXX wildcard → default. Null stays distinct from "no match" so callers can tell them apart.

Why

The LLM was being handed response schemas that included readOnly fields in the input surface and vice-versa — it would either send server-computed fields on creates (rejected) or not know response-only fields existed. Multi-status specs (e.g. 200/201 returning different shapes) also collapsed to whichever schema preferredContent happened to pick first.

Test plan

  • response-fidelity.test.ts (new) — 8 tests across 4 scenarios
    • Multi-status: 200 and 201 both preserved, outputSchema prefers 200, invoke() tags matchedResponseStatus for 200/201/500
    • readOnly stripped from POST body + required, kept on GET response, kept on POST's own response
    • writeOnly kept on POST body, stripped from response + required
    • Documented response headers lifted with name/schema/description
  • Cycle guard in filterSchemaForDirection — real-world specs (Cloudflare, Stripe) with circular $refs no longer blow the stack
  • bunx vitest run passes across the package

…iteOnly filtering

Extract the full { [status]: OperationResponse } map instead of only picking
a single 2xx output schema, lift documented response headers with their
schemas, and filter readOnly fields out of input schemas / writeOnly fields
out of output schemas. invoke() now records which documented status the
response matched (exact → NXX → default), returned as matchedResponseStatus
and as a span attribute.

RhysSullivan commented Apr 20, 2026 •

Copy link
Copy Markdown
Collaborator Author

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 9d4cfc3 Apr 20 2026, 10:20 PM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing 9d4cfc3 Commit Preview URL

Branch Preview URL
Apr 20 2026, 10:20 PM

@pkg-pr-new

pkg-pr-new Bot commented Apr 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor/sdk

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/sdk@355

@executor/plugin-file-secrets

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-file-secrets@355

@executor/plugin-google-discovery

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-google-discovery@355

@executor/plugin-graphql

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-graphql@355

@executor/plugin-keychain

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-keychain@355

@executor/plugin-mcp

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-mcp@355

@executor/plugin-oauth2

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-oauth2@355

@executor/plugin-onepassword

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-onepassword@355

@executor/plugin-openapi

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-openapi@355

@executor/plugin-workos-vault

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-workos-vault@355

executor

npm i https://pkg.pr.new/RhysSullivan/executor@355

commit: 9d4cfc3

@RhysSullivan
RhysSullivan deleted the rs/openapi-response-fidelity branch June 11, 2026 08:01
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.

1 participant