Prompting

Prompt Optimization

Optimization removes what does not change the result and restructures what remains. PromptFlowEngine’s optimizer generates candidates, verifies that every requirement, variable, and code block survives, and explains each change.

What Is Prompt Optimization?0:49 · beginner

What the optimizer changesBeginner

It normalizes whitespace, removes verbatim repeats and filler phrases, and in structured mode reorganizes the prompt into task, requirements, and delimited input. It never invents content: missing information is reported as “needs your input”.

Measure, do not assumeIntermediate

A shorter prompt is better only if answers stay as good. Compare token counts and the engine’s quality score, then run your regression tests (PromptOps Lab → Regression tests) on the optimized version.

Structured data: JSON versus TOONIntermediate

For uniform arrays of records, TOON writes the keys once as a header and the values as rows. The converter recommends it only when decoding it back gives the identical JSON.

Caching opportunitiesAdvanced

Keep the stable part of a prompt (instructions, examples, tool definitions) at the beginning and identical between requests, and put the variable part last. Providers that support prompt caching can then serve the prefix at a discount.

Model routingAdvanced

Sending simple tasks to a smaller model and hard ones to a larger model can cut cost more than any wording change. Route only after measuring quality per task type.

Key takeaways

  • Optimize, then verify with tests.
  • Stable prefixes enable caching.
  • Routing often saves more than rewording.
Optimize a prompt in the WorkspaceSimulate cost in the PromptOps Lab