Skip to main content
Glama
yanlong-iao

Ultimate Prompt Optimizer

by yanlong-iao

Optimize prompt (iterative)

optimize_prompt_via_api

Iteratively rewrite a prompt with template-based rounds, applying requirements while checking and repairing LangGPT structure, dangling references, and lost placeholders.

Instructions

Iteratively rewrite a prompt with the built-in template library (see list_templates): round 1 optimizes with a strategy template (default: langgpt-strict for system prompts, user-basic for user prompts); rounds 2..N apply your requirements with the iterate template, which sees both the original draft and the latest version. Every round is checked for LangGPT structure, dangling and lost {{placeholders}}, which are repaired automatically. Cost: 1 API call per round (+1 repair if needed). Uses a prompt-optimizer Docker deployment instead only if PO_BASE_URL is configured and PO_BACKEND allows it. For score-driven optimization with test cases, use auto_optimize_prompt.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNosystem = role/system prompt; user = a single one-off requestsystem
promptYesDraft prompt to optimize
roundsNo1 = optimize only; each extra round is an iterate pass
backendNoOverride PO_BACKEND for this call
templateNoOptimize template id: langgpt-strict | general | output-format | analytical | user-basic | user-professional | user-planning | custom id
autoRepairNo
showHistoryNo
requirementsNoWhat the iterate rounds should change, e.g. 'reply as a Markdown table; max 200 words'
enforceLangGPTNoValidate & repair LangGPT structure (default: true for system mode)
iterateTemplateNoIterate template id (default iterate)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.0

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does: it discloses cost (1 API call per round, +1 for repair), automatic validation/repair of LangGPT structure, dangling <References> and lost {{placeholders}}, and the backend-selection precondition. This is exactly the operational context an agent needs before committing API calls.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core action and the round model, and every sentence carries operational detail (cost, repair, backend, alternative). It is a dense single paragraph, so a reader must work a little to extract the exclusions, but there is no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 10-parameter, no-annotation, no-output-schema tool, the description covers the workflow, cost, defaults, repair behavior and sibling routing. The main residual gap is what the response actually contains (e.g., what showHistory yields), which the agent must infer.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is already 80%, so the baseline is 3. The description adds real value on top: the meaning of rounds 2..N, the default template selection per mode, and the fact that the iterate template sees both the original draft and the latest version. It does not elaborate on autoRepair/showHistory/enforceLangGPT beyond their schema defaults.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('iteratively rewrite a prompt') and names the mechanism (built-in template library, round 1 strategy template, rounds 2..N iterate template). It explicitly distinguishes itself from the sibling auto_optimize_prompt, so an agent can separate the two without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit routing: use auto_optimize_prompt for score-driven optimization with test cases, and use the Docker backend only when PO_BASE_URL is configured and PO_BACKEND allows it. Defaults per mode are also stated (langgpt-strict for system, user-basic for user).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.