Skip to main content
Glama

loop_optimization

Automates prompt optimization by running test cases, scoring responses, and iteratively applying improvements until performance threshold is reached or max iterations are exhausted.

Instructions

Run the full optimization loop until the threshold is met or max iterations reached.

Like start_optimization_session but auto-applies each suggestion and repeats.

Prerequisites: same as start_optimization_session.

Loop:

  1. Run all test cases, score responses, call post_test_result for each.

  2. Call get_regression_status.

  3. If ALL scores >= threshold AND iteration >= 1 → SUCCESS.

  4. If iteration >= maxIterations → EXHAUSTED. Report best result.

  5. Analyse failures, write improved prompt (targeted — fix pattern, keep what works).

  6. Call post_prompt_suggestion then apply_suggestion (auto authorised in loop mode).

  7. Go to 1.

Do NOT stop after the first pass because it is passing — first pass is a baseline. Always run at least one improvement cycle.

After the loop: call pull_ui_history, save optimization results locally, call save_system_prompt_template with the best prompt found.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspaceIdYes
thresholdNoPass score 0–100 (default 70)
maxIterationsNoMax loop iterations (default 5)
Behavior5/5

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

With no annotations, the description fully describes the loop steps, success/exhaustion conditions, prompt improvement, and post-loop actions, ensuring complete behavioral transparency.

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?

The description is detailed but well-structured with a list. It is front-loaded with purpose and each sentence adds value, though slightly verbose for a 5.

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

Completeness5/5

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

Given the complexity of a loop optimization tool and no output schema, the description covers the loop algorithm, conditions, and post-loop steps completely.

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

Parameters3/5

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

The input schema already describes threshold and maxIterations; workspaceId lacks description. The description adds no further parameter meaning, so baseline 3 is appropriate.

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?

The description clearly states it runs a full optimization loop until threshold or max iterations, and distinguishes from sibling start_optimization_session by noting auto-application and repetition.

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?

Specifies prerequisites same as start_optimization_session, explicitly warns not to stop after first pass, and requires at least one improvement cycle. Provides clear when and when-not to use.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jurek-f/prompt-lab-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server