Skip to content

Comments

feat: structured output support for schema inference and runtime extraction#191

Merged
cristipufu merged 2 commits intomainfrom
feat/structured-output-support
Feb 22, 2026
Merged

feat: structured output support for schema inference and runtime extraction#191
cristipufu merged 2 commits intomainfrom
feat/structured-output-support

Conversation

@cristipufu
Copy link
Member

Summary

  • Schema inference: get_entrypoints_schema() now returns the Pydantic model JSON schema from response_format on output executors, instead of the default messages schema
  • Runtime extraction: Structured output is returned as a parsed dict rather than wrapped in messages — works for both streaming and non-streaming paths
  • Sequential workflow fix: Output extraction and schema inference now fall back to scanning all workflow executors when the output executor is an internal adapter (e.g. _EndWithConversation in sequential orchestrations)
  • Streaming fix: Token concatenation no longer corrupts output with "\n\n" separators
  • New sample: sequential-structured-output — researcher + editor pipeline producing a typed CityInfo Pydantic model
  • Tests: E2E streaming and non-streaming tests for both single-agent and sequential structured output workflows

Changes

Runtime (runtime.py)

  • _extract_workflow_output() checks AgentResponse.value for structured data
  • _try_parse_structured_output() validates concatenated streaming tokens against the response_format Pydantic model
  • _get_output_response_format() falls back to scanning all workflow executors for the last AgentExecutor with a response_format

Schema (schema.py)

  • _extract_output_schema() same fallback: scans all workflow executors when output executors don't have a response_format

Tests (test_schema.py)

  • TestStructuredOutput — schema extraction, streaming, and non-streaming for single-agent workflows
  • TestSequentialStructuredOutput — same coverage for sequential workflows with 3 chained agents

Sample (samples/sequential-structured-output/)

  • Researcher → editor sequential pipeline with CityInfo structured output
  • Includes README.md, pyproject.toml, agent_framework.json, uipath.json, entry-points.json

Test plan

  • All 116 existing tests pass
  • New structured output tests pass (schema, streaming, non-streaming)
  • New sequential structured output tests pass
  • uipath init generates correct entry-points.json with CityInfo schema for the new sample

🤖 Generated with Claude Code

…result

- Infer output JSON schema from response_format on output executors in
  get_entrypoints_schema(), returning the Pydantic model schema instead
  of the default messages schema.
- Fix runtime result extraction to return structured dict output instead
  of wrapping it in messages: check AgentResponse.value for non-streaming,
  concatenate streaming tokens and parse via response_format for streaming.
- Fix streaming token corruption caused by joining with "\n\n" separators.
- Update structured-output sample to pass response_format via
  default_options so it actually reaches the LLM API.
- Add missing agent_framework.json for sequential, magentic, and
  structured-output samples.
- Update samples README table with all samples ordered by difficulty.
- Add tests for schema inference, non-streaming result, and streaming
  result (matching production behavior with chunked AgentResponseUpdate
  tokens).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cristipufu cristipufu force-pushed the feat/structured-output-support branch 2 times, most recently from e450650 to ed3c138 Compare February 21, 2026 18:05
The runtime and schema extraction only checked output_executors for
response_format, which missed sequential workflows where the output
executor is _EndWithConversation (not an AgentExecutor). Add fallback
to scan all workflow executors and pick the last agent's response_format.

Includes e2e streaming tests and a sequential-structured-output sample.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cristipufu cristipufu force-pushed the feat/structured-output-support branch from ed3c138 to 3e6ff28 Compare February 22, 2026 05:20
@cristipufu cristipufu self-assigned this Feb 22, 2026
@cristipufu cristipufu merged commit 675fe21 into main Feb 22, 2026
46 checks passed
@cristipufu cristipufu deleted the feat/structured-output-support branch February 22, 2026 05:23
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