improve_generation_prompt
Refine 3D printing prompts by adding physical constraints to fix structural issues while preserving original intent, with a sanity check to avoid contradictions.
Instructions
Generate an improved prompt from feedback.
Adds physical constraints to the original prompt to address
printability and structural issues, without modifying the
creative intent.
Patent KILN-010 claim 51 — the improved prompt is run
through a three-check sanity gate (no contradictions, fits
the provider budget, ≥70% original-token overlap so intent
is preserved). When ``enforce_sanity=True`` (default) and
the gate fails, this tool refuses with
``code="SANITY_GATE_FAILED"`` and returns the failure list
instead of a contradictory prompt. Callers that genuinely
want the failed prompt — for inspection, repair, or model
self-correction — set ``enforce_sanity=False`` and read
``improved_prompt.sanity`` from the response.
Args:
original_prompt: The original generation prompt.
failure_mode: Optional failure mode string.
max_overhang_angle: Maximum overhang angle detected.
min_wall_thickness: Minimum wall thickness detected.
has_bridges: Whether bridges were detected.
iteration: Which retry iteration this is.
file_path: Optional path to the STL file for structural
analysis. When provided, the tool also analyzes
structural risks and folds them into the improved
prompt.
enforce_sanity: When True (default), refuse the
response if the prompt sanity gate fails. Pass
False to receive a contradictory prompt anyway —
useful when the agent intends to repair it before
sending to the generator.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | No | ||
| iteration | No | ||
| has_bridges | No | ||
| failure_mode | No | ||
| enforce_sanity | No | ||
| original_prompt | Yes | ||
| max_overhang_angle | No | ||
| min_wall_thickness | No |