prompt_optimize
Rewrite a prompt using an LLM and failing eval scenarios, then review the proposed content, diff, and validation issues or save it as a new prompt version.
Instructions
LLM-assisted prompt rewrite from a failing eval run — the portal's
/admin/prompts/{id}/optimize, non-streaming. Same helpers: the failing
scenarios of run_id and the prompt's newest version go into
build_optimizer_meta_prompt, and model_id writes the rewrite.
Returns {proposal: {content, chars}, diff_stat (vs the current newest
version), validation: {problems}, failing_scenarios}. With
confirm=true the proposal is saved IN-PROCESS as version N+1 (so a
half-Arabic body never round-trips through the client) after the same
validation gate create_version uses; it is NOT served until you pin it
(prompts action=serve). Takes as long as one LLM call.Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"prompt_id": "<prompt_id>",
"run_id": "<run_id>",
"model_id": "<model_id>"
},
"name": "prompt_optimize"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| env | No | Config branch: which `environment` rows of the AI config DB to read/write. staging = the editable working set (default); prod = what production serves. | staging |
| notes | No | Notes for the saved version. | |
| run_id | Yes | Eval run whose FAILING scenarios drive the rewrite. | |
| confirm | No | false (default) = return the proposal only. true = also save it as a NEW prompt version (not served; pin it with prompts action=serve). | |
| model_id | Yes | agent_models row (a chat model) that writes the rewrite. | |
| prompt_id | Yes | Prompt slot to rewrite (its NEWEST version is the input). | |
| include_content | No | Return the proposed prompt text (default true). | |
| override_validation | No | Save even if the proposal fails prompt validation (needs confirm=true; audited). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |