feat: Add structured output support with generate_program_structured! for E2E tests (#65)#67
Conversation
… for E2E tests - Implement PtcRunner.Schema.to_llm_schema/0 with flattened schema optimized for LLMs - Use anyOf pattern to list all operations at top level, avoiding recursion - Add PtcRunner.TestSupport.LLMClient.generate_program_structured!/1 for structured output mode - Uses ReqLLM.generate_object! for guaranteed valid JSON from LLMs - Add E2E tests for both text mode (text mode) and structured output mode - E2E tests verify filter, sum, and chained operations work correctly - Addresses issue #65 review comments on schema validation and error handling 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
PR Review: feat: Add structured output support with generate_program_structured! for E2E tests (#65)SummaryThis PR adds structured output support for E2E tests by introducing What's Good
Issues (Must Fix)
Suggestions (Optional)
SecurityNo security concerns. The changes are additive and confined to test infrastructure. VerdictRequest Changes - The missing unit tests for |
|
@claude please fix these issues from PR review: Issue 1: Missing unit tests for to_llm_schema/0Location: Fix: Add unit tests for
Follow the exact testing patterns from lines 317-471. The key difference is that Please fix ALL issues above in a SINGLE commit. Make minimal changes to resolve each issue. |
Auto-Triage SummaryDecisions Made
Status
Next StepsClaude Code will process the fix request and add comprehensive unit tests for |
Adds 13 new tests for the to_llm_schema/0 function following the same patterns as the existing to_json_schema/0 tests. Tests verify: - Basic schema structure with title, type, properties, anyOf - Program property with correct structure - Correct count of 33 operation schemas - Each operation has required structure - Literal operation schema correctness - Operations with no fields have only 'op' as required - Operations with optional fields exclude them from required - Expr types use inline object schema (not $ref) - List of expr types have correct inline schema - List of string types have correct schema - Non-negative integer types have minimum constraint - Recursive operations like pipe validate correctly - Generated schema is valid JSON Fixes issue from PR #67 review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
SummaryFixed the missing unit tests for Changes MadeAdded 13 comprehensive unit tests in a new describe block in
All tests follow the exact patterns from the existing Test Results
Commit: |
PR Review: feat: Add structured output support with generate_program_structured! for E2E tests (#65)SummaryWell-implemented PR that adds LLM structured output support with a flattened JSON Schema ( What's Good
Issues (Must Fix)None identified. The implementation is complete and consistent. Suggestions (Optional)
SecurityNo concerns. The implementation does not introduce new attack vectors:
VerdictApprove - Implementation is complete, well-tested, and follows project conventions. The flattened schema approach is the right solution for LLM structured output, and the code quality is high. |
Summary
Implements structured output support for E2E tests using ReqLLM's
generate_object!API. This guarantees valid JSON output from LLMs, eliminating markdown fence cleanup issues and improving test reliability.PtcRunner.Schema.to_llm_schema/0with flattened schema optimized for LLMsPtcRunner.TestSupport.LLMClient.generate_program_structured!/1for structured output modeImplementation Details
Schema Flattening (
to_llm_schema/0)anyOfpattern to list all operations at the top level$refpatterns that LLMs struggle withStructured Output Function (
generate_program_structured!/1)taskparameter (simplified API compared to text mode)ReqLLM.generate_object!for guaranteed JSON outputE2E Tests
mix test --include e2eTest Plan
Fixes #65