docs/user/context-mode_en.md
This document explains how to use Context Mode in Prompt Optimizer: what it is, when to use it, and common pitfalls.
In the UI, Context Mode is the top-level Function Mode: Context. It provides two sub-modes:
When “single prompt optimization” feels unstable, it often lacks real context: prior constraints, examples, available tools, or variable values.
Context Mode helps by sending your configured messages / variables / tools together as the optimization context, so the output better matches the real execution environment.
Use this table as a quick decision:
| Your goal | Recommended sub-mode |
|---|---|
| You are doing role-play or multi-turn chat, and want to optimize one specific system/user message while keeping style consistent with the conversation | Multi-message |
| You have one user prompt, but many reusable parameters (name/date/spec/output format) and want to manage them via {{var}} for reuse & testing | Variable |
| You want to configure tools (Function Calling) and verify tool behavior during testing | Variable |
Both sub-modes support the test area (multi-column comparison) on the right.
Best for: optimizing a single system/user message inside a conversation (not generating a reply).
Add/edit conversation messages on the left:
You must select a system/user message; otherwise the Optimize button is disabled.
Start with the built-in recommended template:
This template enforces a few critical rules:
{{var}} placeholders as-isMulti-message optimization uses a per-message version chain:
If the optimization gets worse, switch versions (e.g. back to V0) instead of manual copy/paste rollback.
Treat testing as acceptance:
{{var}})Best for: optimizing one user prompt with reusable variables and optional tools.
Example:
Create a plan for {{product_name}}.
Output format: {{output_format}}.
Constraints: budget {{budget}}, deadline {{deadline}}.
Tip: typing {{}} often triggers variable auto-completion.
If you still see {{var}} in preview/test outputs, that variable has no value. Set it first, then re-run preview or test.
If your prompt is meant to run with tools:
Variable-mode templates usually focus on rewriting the user prompt to be clear, executable, and verifiable, while preserving all {{var}} placeholders.
Recommended starting template:
If you are preparing a reply for Issue #240, you can link this doc (docs/user/context-mode_en.md) and quote the decision table in Section 2. That usually helps users pick the correct sub-mode quickly.