Skip to content

feat: add openai and claude structured output config#5763

Open
WashingtonKK wants to merge 4 commits into
superplanehq:mainfrom
WashingtonKK:ai/structured-output
Open

feat: add openai and claude structured output config#5763
WashingtonKK wants to merge 4 commits into
superplanehq:mainfrom
WashingtonKK:ai/structured-output

Conversation

@WashingtonKK

Copy link
Copy Markdown
Collaborator

Summary

This adds structured output as a configuration option for the following components:

  • claude.textPrompt
  • openai.textPrompt

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
@superplanehq-integration

Copy link
Copy Markdown

👋 Commands for maintainers:

  • /sp start - Start an ephemeral machine (takes ~30s)
  • /sp stop - Stop a running machine (auto-executed on pr close)

Comment thread pkg/integrations/claude/text_prompt.go
@superplane-gh-integration-9000

superplane-gh-integration-9000 Bot commented Jun 29, 2026

Copy link
Copy Markdown

Risk: 32/100 (low)

Summary

Adds a new shared structuredoutput package and wires it into both the OpenAI and Claude text-prompt components, letting users define typed output fields that are compiled into JSON Schemas sent to each provider's structured-output API.

Concerns

  • JSON unmarshal failure on model response is silently swallowed; no warning when structured output is configured but model returns non-JSON.
  • OutputFields typed as any in both spec structs; relies on runtime mapstructure decode rather than a concrete type.
  • structuredoutput.Decode is called twice per request lifecycle (Setup and Execute), duplicating work.
  • maxNesting=3 constant is UI-only; Validate does not enforce a depth limit on server-submitted schemas.
  • No test covering the path where a schema is configured but JSON unmarshal silently fails and Parsed is nil.
  • Claude output_config request field name should be verified against the live Anthropic Responses API spec.

Recommended reviewers: forestileao, felixgateru

…chema

Addresses Cursor Bugbot review on PR superplanehq#5763: claude.textPrompt Setup only
checked the schema root was an object, while the field description and docs
require every object to set additionalProperties:false (an Anthropic
requirement). Such schemas passed Setup and failed later at the Claude API,
unlike openai.textPrompt which rejects them at Setup.

Add validateClaudeOutputSchema: a recursive check that every object sets
additionalProperties:false (walking properties, items, anyOf/allOf/oneOf,
$defs). It intentionally does NOT require all properties in "required" —
Anthropic permits optional fields, unlike OpenAI strict mode.

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Set node-level metadata in Setup for claude.textPrompt and openai.textPrompt
so the configured model, max tokens (Claude), and whether structured output
is enabled are visible on the node in the UI without opening its config.
Mirrors the existing node-metadata pattern (e.g. digitalocean IndexKB).

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fbf60f8. Configure here.

Comment thread pkg/integrations/openai/structured_output.go Outdated
Replace the raw JSON Schema input on claude.textPrompt and openai.textPrompt
with a guided builder: users define output fields (name, type, description,
required) including nested objects and lists, and the backend assembles the
JSON Schema. Provider rules are handled automatically -- Anthropic omits
optional fields from "required"; OpenAI strict mode lists every field and
makes optional ones nullable. Shared logic lives in the new
pkg/integrations/structuredoutput package.

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
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