Commit 70cdf24
authored
Put the user request last in the planner prompt (#7773)
Two changes to the `pdf_edit` selection prompt.
**The user's request moves to the end.** When a prompt exceeds the
model's context, Ollama keeps the tail and discards the head. The
request was the second line, so it was the first thing thrown away.
Ending with it makes the most important line the most likely to survive.
Reproduced on a local qwen3:8b before the change: five completely
different requests - convert to Word, merge two files, run OCR, add a
password, add a watermark - run sequentially at temperature 0 through
the production prompt shape all returned `COMPRESS_PDF`, and every one
reported `prompt_tokens: 2050` against a much larger prompt. The model
was not choosing badly; it was answering a question it had never been
shown.
This is defensive rather than a fix on its own - the real repair is
giving the model a context window large enough, and a prompt small
enough, to avoid truncation entirely. But the ordering is free and
correct regardless of context size.
**The duplicated unavailable-operations list is removed from the user
prompt.** It was rendered twice, once in the system prompt and again in
the user prompt. It is also counterproductive: it spends tokens teaching
the model names it must not use, and `handle()` already rejects a plan
referencing an unavailable operation in Python afterwards. The
system-prompt copy stays, so the model can still explain that an
operation exists but is not available here.
The existing test that asserted the list appears in the user prompt now
asserts it appears in the system prompt and not the user prompt.1 parent cbc8af1 commit 70cdf24
2 files changed
Lines changed: 17 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | | - | |
286 | | - | |
287 | | - | |
| 285 | + | |
288 | 286 | | |
289 | 287 | | |
290 | 288 | | |
| |||
330 | 328 | | |
331 | 329 | | |
332 | 330 | | |
333 | | - | |
334 | 331 | | |
335 | 332 | | |
336 | 333 | | |
| |||
343 | 340 | | |
344 | 341 | | |
345 | 342 | | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | 343 | | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | 344 | | |
357 | | - | |
358 | 345 | | |
359 | | - | |
360 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
361 | 351 | | |
362 | 352 | | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
376 | 357 | | |
377 | 358 | | |
378 | 359 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
| |||
494 | 493 | | |
495 | 494 | | |
496 | 495 | | |
497 | | - | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
498 | 499 | | |
499 | | - | |
500 | | - | |
501 | | - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
502 | 503 | | |
503 | 504 | | |
504 | 505 | | |
| |||
0 commit comments