Skip to content

Conversation

@thomasrowe5
Copy link

…redOutput (#33720)

@changeset-bot
Copy link

changeset-bot bot commented Nov 3, 2025

⚠️ No Changeset found

Latest commit: b78d57a

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

@thomasrowe5
Copy link
Author

✨ Summary
Adds support for propertyOrdering in Gemini structured output schemas within withStructuredOutput().
This enables developers to define or preserve ordered field generation when using Vertex AI Gemini models.
🧩 Context
Google’s Gemini structured output schema supports a propertyOrdering array that defines the order in which model output fields are generated.
Without this, Gemini ignores ordering, leading to undesirable outputs for order-sensitive tasks (e.g. reasoning traces or step-based scribing).
🛠️ Implementation
Added helper withPropertyOrdering() in chat_models.ts to automatically infer property ordering from the provided schema when missing.
Integrated the helper into schemaToGeminiParameters() path within ChatGoogleBase.withStructuredOutput.
No other behavioral changes.
✅ Testing
All google-common provider tests pass.
Full monorepo test suite passes except a single flaky math_utils timeout in @langchain/core (unrelated).
📚 Example
const schema = z.object({
reason: z.string(),
decision: z.string(),
});
const model = new ChatGoogleVertexAI().withStructuredOutput(schema);
→ Automatically constructs propertyOrdering: ["reason", "decision"].
🔗 Related
Fixes #33720
PR authored by @thomasrowe5

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