Skip to content

Retain rejected output in TypeScript and Python failures - #457

Draft
robgruen wants to merge 1 commit into
mainfrom
dev/robgruen/data_on_error
Draft

robgruen wants to merge 1 commit into
mainfrom
dev/robgruen/data_on_error

Conversation

@robgruen

@robgruen robgruen commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #116.

  • Add optional data: unknown and responseText to TypeScript failures, and value: object, response_text, and has_value to Python failures.
  • Retain rejected inputs in the TypeScript, Zod, program, and Python validators, including when those validators are called directly.
  • Preserve custom failure metadata and the latest useful rejected candidate when a repair request fails or returns unparseable output.
  • Keep successful result shapes, human-readable diagnostics, exception behavior, and the existing language-specific repair policies unchanged. Retain bounded failure context, not an attempt history.
  • Document payload availability, success discriminators, cross-attempt context, and sensitive-output handling in package READMEs and public usage guides.

Validation

  • TypeScript source build and test compilation passed.
  • Focused TypeScript failure, TypeScript validator, Zod, program, and model regression suites passed.
  • Python failure, translator, validator, and model tests: 44 passed; 5 existing snapshots unchanged.
  • Pyright over the Python source and affected callers: 0 errors or warnings.
  • git diff --check passed.

Compatibility

Failure payloads are unvalidated and must not be treated as the success type. Use success in TypeScript and isinstance in Python to distinguish outcomes. Python's has_value distinguishes unavailable data from explicit None or falsy values. The latest response text may be from a later repair attempt than the retained rejected candidate.

Matching .NET implementation: microsoft/typechat.net#338 (standalone PR against main).

Preserve unvalidated candidates, raw response text, custom failure metadata, and repair context without changing success results or repair limits. Add regression coverage and document the additive failure payload APIs.

Co-authored-by: Copilot <[email protected]>
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.

Give access to data if result.success === false

1 participant