Skip to content

Conversation

@monadoid
Copy link
Contributor

@monadoid monadoid commented Jan 16, 2026

why

Better to have in stainless yaml than gen-openapi script + some minor cleanup.

what changed

test plan


Summary by cubic

Moved Stainless compatibility transforms from gen-openapi.ts into stainless.yml and removed the v2 string model config. This keeps openapi.v3.yaml faithful to the Fastify/Zod output and applies compatibility at SDK generation, improving CI stability and supporting STG-1149.

  • Refactors
    • Removed string-based post-processing from gen-openapi.ts.
    • Added openapi.transforms in stainless.yml to:
      • Remove propertyNames.
      • Set targeted additionalProperties to true.
      • Add ProxyConfigList title for the proxies array.
    • Dropped ModelConfigString; ModelConfig is now object-only. Updated the API client to convert agentConfig.model to the wire ModelConfig.
    • Added openapi.code_samples: mintlify. Updated openapi.v3.yaml to the raw schema (propertyNames present, additionalProperties {}, no injected titles).

Written for commit 6cabbd3. Summary will update on new commits.

@changeset-bot
Copy link

changeset-bot bot commented Jan 16, 2026

⚠️ No Changeset found

Latest commit: 6cabbd3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jan 16, 2026

✱ Stainless preview builds

This PR will update the stagehand SDKs with the following commit message.

feat: move Stainless compatibility transforms from gen-openapi.ts into stainless.yml

Edit this comment to update it. It will appear in the SDK's changelogs.

stagehand-java studio · code · diff

Your SDK built successfully.
generate ⚠️lint ❗test ❗

New diagnostics (1 note)
💡 Model/IsIndirect: `#/resources/sessions/models/model_config` references a schema that has `$ref: #/components/schemas/ModelConfigObject`, but could potentially reference `#/components/schemas/ModelConfigObject` directly.
stagehand-openapi studio · code · diff

Your SDK built successfully.
generate ✅lint ⏳test ⏳

New diagnostics (1 note)
💡 Model/IsIndirect: `#/resources/sessions/models/model_config` references a schema that has `$ref: #/components/schemas/ModelConfigObject`, but could potentially reference `#/components/schemas/ModelConfigObject` directly.
stagehand-kotlin studio · code · diff

Your SDK built successfully.
generate ⚠️lint ✅test ✅

New diagnostics (1 note)
💡 Model/IsIndirect: `#/resources/sessions/models/model_config` references a schema that has `$ref: #/components/schemas/ModelConfigObject`, but could potentially reference `#/components/schemas/ModelConfigObject` directly.
stagehand-typescript studio · code · diff

Your SDK built successfully.
generate ✅build ✅lint ✅test ❗

npm install https://pkg.stainless.com/s/stagehand-typescript/ebda9071b1f232171c093b1ab9722b78b6f38432/dist.tar.gz
New diagnostics (1 note)
💡 Model/IsIndirect: `#/resources/sessions/models/model_config` references a schema that has `$ref: #/components/schemas/ModelConfigObject`, but could potentially reference `#/components/schemas/ModelConfigObject` directly.
stagehand-php studio · code · diff

Your SDK built successfully.
generate ✅lint ✅test ✅

New diagnostics (1 note)
💡 Model/IsIndirect: `#/resources/sessions/models/model_config` references a schema that has `$ref: #/components/schemas/ModelConfigObject`, but could potentially reference `#/components/schemas/ModelConfigObject` directly.
stagehand-csharp studio · code · diff

Your SDK built successfully.
generate ⚠️lint ❗test ✅

New diagnostics (1 note)
💡 Model/IsIndirect: `#/resources/sessions/models/model_config` references a schema that has `$ref: #/components/schemas/ModelConfigObject`, but could potentially reference `#/components/schemas/ModelConfigObject` directly.
stagehand-go studio · code · diff

Your SDK built successfully.
generate ✅lint ❗test ❗

go get github.com/stainless-sdks/stagehand-go@b6a2685cbc4730c17103138a3c235bbd4af58b57
New diagnostics (1 note)
💡 Model/IsIndirect: `#/resources/sessions/models/model_config` references a schema that has `$ref: #/components/schemas/ModelConfigObject`, but could potentially reference `#/components/schemas/ModelConfigObject` directly.
stagehand-python studio · conflict

Your SDK built successfully.

New diagnostics (1 note)
💡 Model/IsIndirect: `#/resources/sessions/models/model_config` references a schema that has `$ref: #/components/schemas/ModelConfigObject`, but could potentially reference `#/components/schemas/ModelConfigObject` directly.
stagehand-ruby studio · conflict

Your SDK built successfully.

New diagnostics (1 note)
💡 Model/IsIndirect: `#/resources/sessions/models/model_config` references a schema that has `$ref: #/components/schemas/ModelConfigObject`, but could potentially reference `#/components/schemas/ModelConfigObject` directly.
stagehand-cli studio · code · diff

Your SDK built successfully.
generate ✅lint ❗test ❗

New diagnostics (1 note)
💡 Model/IsIndirect: `#/resources/sessions/models/model_config` references a schema that has `$ref: #/components/schemas/ModelConfigObject`, but could potentially reference `#/components/schemas/ModelConfigObject` directly.

This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
Last updated: 2026-01-17 18:23:32 UTC

@monadoid monadoid marked this pull request as ready for review January 17, 2026 00:38
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 17, 2026

Greptile Summary

Refactored OpenAPI post-processing from string-based regex transformations in gen-openapi.ts to declarative JSONPath-based transforms in stainless.yml. This keeps openapi.v3.yaml faithful to the Fastify/Zod source while applying Stainless compatibility at SDK generation time.

  • Removed ModelConfigStringSchema from the API schema union (replaced by object-only format)
  • Added explicit wireAgentConfig construction in api.ts:355 to transform model config before sending to API
  • Moved all compatibility transforms (propertyNames removal, additionalProperties conversion, ProxyConfigList title) from gen-openapi.ts script to stainless.yml config
  • The raw OpenAPI spec now contains propertyNames and additionalProperties: {} as emitted by Zod

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Clean refactoring that moves string-based post-processing to declarative config. The change maintains backward compatibility through proper model config transformation in api.ts and is well-isolated to SDK generation tooling.
  • No files require special attention

Important Files Changed

Filename Overview
packages/server/scripts/gen-openapi.ts Removed string-based post-processing transformations and ModelConfigStringSchema reference; all compatibility transforms moved to stainless.yml
stainless.yml Added openapi.transforms section with JSONPath-based transformations for Stainless compatibility
packages/core/lib/v3/types/public/api.ts Removed deprecated ModelConfigStringSchema; ModelConfigSchema now only accepts object format
packages/core/lib/v3/api.ts Added explicit wireAgentConfig construction to handle model config transformation before API calls

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Script as gen-openapi.ts
    participant Fastify as Fastify/Zod
    participant YAML as openapi.v3.yaml
    participant Stainless as Stainless SDK Gen
    participant SDK as Generated SDK

    Dev->>Script: Run npm run gen-openapi
    Script->>Fastify: Generate OpenAPI spec
    Fastify->>YAML: Output raw schema (with propertyNames, additionalProperties: {})
    Note over YAML: Raw Fastify+Zod output<br/>(faithful to source)
    
    Dev->>Stainless: Run SDK generation
    Stainless->>YAML: Read openapi.v3.yaml
    Stainless->>Stainless: Apply transforms from stainless.yml
    Note over Stainless: Remove propertyNames<br/>Set additionalProperties: true<br/>Add ProxyConfigList title
    Stainless->>SDK: Generate type-safe SDK
    
    Note over Script,SDK: Before: Script did string replacements<br/>After: Stainless applies transforms
Loading

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 5 files

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="stainless.yml">

<violation number="1" location="stainless.yml:8">
P2: The new top-level `openapi` block duplicates an existing `openapi` section later in the file, so YAML will overwrite the earlier `code_samples` setting. Merge `code_samples: mintlify` into the existing `openapi` block to avoid losing the config.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment on lines -201 to -205
// 4. Fix StreamEventSystemData*.result to have x-stainless-any: true
yaml = yaml.replace(
/(StreamEventSystemData(?:Output)?:\s+type: object\s+properties:\s+status:[\s\S]+?)(result:\s+description: [^\n]+)\n(\s+error:)/g,
"$1$2\n x-stainless-any: true\n$3",
);
Copy link
Member

Choose a reason for hiding this comment

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

looks like this is missing in the final transforms

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.

3 participants