Visual Artifact Inspector and Tool Calling Healer Script
Develop an automated visual quality assurance script that evaluates generated images and calls remediation tools when defects are found.
Use this template when setting up closed-loop quality control agents that review AI-generated images for artifacts and automatically invoke restoration tools. It delivers a self-healing evaluation script.
Role: Multimodal Quality Assurance Lead specializing in automated visual evaluation and self-healing agent pipelines.
Context
- Batch Target Directory: {{asset_batch_directory}}
- Vision Evaluation Tool: {{vision_evaluator_tool}}
- Defect Tolerance Score: {{defect_tolerance_threshold}}
- Remediation Tool Endpoint: {{remediation_tool_endpoint}}
- Logging Format: {{telemetry_export_format}}
Task
Create an automated evaluation and self-healing script that calls a multimodal vision tool to score generated image quality and conditionally triggers targeted upscaling or face restoration tools.
Method
- Scan {{asset_batch_directory}} to discover newly rendered visual assets requiring quality auditing.
- Construct and dispatch an evaluation function call to {{vision_evaluator_tool}} for each image asset.
- Parse the evaluation response to extract anatomical accuracy, blur metrics, and artifact severity scores.
- Compare observed quality scores against the numerical benchmark in {{defect_tolerance_threshold}}.
- If defects exceed tolerance, dynamically construct a remediation tool payload targeting {{remediation_tool_endpoint}}.
- Dispatch remediation tool calls (e.g., face enhancement, sharpening, denoising) and capture corrected outputs.
- Format all evaluation metrics and tool invocation timestamps into {{telemetry_export_format}}.
Constraints
- MUST prevent infinite remediation loops by enforcing a maximum of two healing passes per asset.
- MUST NOT overwrite original source files; all healed assets must use distinct version identifiers.
- MUST validate that evaluation scores fall within the normalized 0.0 to 1.0 range.
- Keep script dependencies limited to standard HTTP and JSON handling packages.
Output format
1. Inspector and Remediation Script
Executable script executing directory scanning, evaluation tool calls, conditional healing, and file management.
2. Tool Invocation Specs
Structured JSON payloads defining the evaluation and remediation function schemas.
3. Log Sample
Example log entries illustrating a flagged defect, subsequent tool call, and final resolution.
Self-review
- Verify that the defect threshold check strictly triggers the remediation endpoint.
- Ensure the loop limit prevents runaway API consumption on corrupted files.
- Check that output paths preserve the original asset intact.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.