Implement structured output for prompt steps (Phase 1)
Add schema validation and retry logic for AI responses:
- Add output_schema, max_retries, plain_text fields to PromptStep
- Add DEFAULT_OUTPUT_SCHEMA with output/reasoning fields
- Implement append_schema_instructions() for prompt augmentation
- Implement validate_schema() using jsonschema library
- Add retry logic with error feedback on validation failure
- Enhance substitute_variables() for nested field access ({var.field})
- Add jsonschema to dependencies
- Update GUI dialog with plain_text checkbox and max_retries spinner
- Add comprehensive tests for structured output and nested access
Tools using plain_text=True bypass validation (current behavior).
Tools without plain_text get structured JSON output with schema enforcement.
Migration Phase 1 complete. Next: Apply plain_text=True to all 72 tools.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
+2
-2
@@ -184,7 +184,7 @@ class TestRunCommand:
|
||||
tool = Tool(
|
||||
name="summarize",
|
||||
steps=[
|
||||
PromptStep(prompt="Summarize: {input}", provider="mock", output_var="summary")
|
||||
PromptStep(prompt="Summarize: {input}", provider="mock", output_var="summary", plain_text=True)
|
||||
],
|
||||
output="{summary}"
|
||||
)
|
||||
@@ -223,7 +223,7 @@ class TestTestCommand:
|
||||
tool = Tool(
|
||||
name="test-me",
|
||||
steps=[
|
||||
PromptStep(prompt="Test: {input}", provider="claude", output_var="result")
|
||||
PromptStep(prompt="Test: {input}", provider="claude", output_var="result", plain_text=True)
|
||||
],
|
||||
output="{result}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user