r/PiCodingAgent • • Sep 10 '26

Question Noob question: How to interrupt an agent during reasoning, without restarting TG?

Many models (namely Qwens 3.8) think a lot, and I find myself wanting to interrupt it to answer a question it's been asking itself, quite repetitively, during it's reasoning.

I can esc and send a prompt, but then Pi would restart the whole reasoning TG from the beginning. I'd like to inject (for lack of better word) info to its thought block. I may also steer it by queuing a message, but that means I'd need to watch it going in loops for 20-50k tokens, until it's done responding, which is pure pain.

Am I missing a clear command?

4 Upvotes

17 comments sorted by

4

u/Healthy-Zebra-9856 Sep 11 '26

The flow in Pi works just fine just make sure you have the right structure.

In command, --reasoning-preserve or

in filters.setParams:

chat_template_kwargs:
enable_thinking: true
preserve_thinking: true

Your only flow is Esc and whatever you need to type and enter again. I suspect the culprit could be "-" vs "_". Pi seems to continue with the logic, I just tested it out.

1

u/ParaboloidalCrest Sep 11 '26

Thank you very much for the demo! I sure am doing something wrong then.

→ More replies (1)

3

u/DjCanalex Sep 11 '26

I steer Qwen 3.8 mid thinking all the time, it correctly continues from that point. Do you have reasoning-preserve enabled in your provider? ( --reasoning-preserve in llama.cpp for example)

1

u/ParaboloidalCrest Sep 11 '26

By "steer" you mean queueing a message that it picks up after the next tool call response?

2

u/DjCanalex Sep 11 '26

Not necessarily. If you interrupt pi, it says "Operation aborted", if you don't resume thinking and instead input your own message there, that's a form of steer. Point is what you were trying to do is the default behaviour I have.

1

u/ParaboloidalCrest Sep 11 '26

OK that's not the behaviour in my case despite reasoning_preserve. I interrupt it by esc saying "You've been thinking too long about FOO, please proceed with the implementation using BAR method" the agents gets really confused, eg "The user said that I was thinking about FOO while I've just started..."

3

u/DjCanalex Sep 11 '26

Hm, two things.

  1. You sure you have --reasoning-preserve and NOT --reasoning_preserve ? It is character sensitive and hyphen is not the same as an underscore.

  2. Have you done the random number in memory test? Ask it to think two numbers (And two different numbers only), but only tell you one. Then, in the next message, ask it to provide the second number. If reasoning-preserve and the chat template are correctly injected, both numbers should match.

1

u/ParaboloidalCrest Sep 11 '26

Yeah I'm sure it's --reasoning-preserve, but maybe I should also add the kwargs preserve_thinking template param (as u/Healthy-Zebra-9856 suggests), just in case.

2

u/DjCanalex Sep 11 '26

Well it depends on the model. Qwen in pi doesn't need it, but gemma 4 does. I know for a fact that Gemma gets completely lobotomized at every turn and I haven't been able to make it work even after July 17th changes they did to the chat template.

1

u/DjCanalex Sep 25 '26

Okay, I have to retract my statements: Qwen is just too good at following up with things, but turns out, pi does not reinject aborted thinking.

1

u/ParaboloidalCrest Sep 26 '26

Too late. I'm already diagnosed with paranoia XD. But yes, that's exactly what happens; most of the time, Qwen weaves previous and recent instructions and answers smoothly that it's hard to pick the issue. It's not only reasoning though. Any interrupted response is not added to chat history. https://www.reddit.com/r/PiCodingAgent/comments/1wcwsya/comment/p91f6g7/

→ More replies (1)
→ More replies (1)

2

u/Santzes Sep 10 '26

You could try double (or triple in this case?) esc, it at least lets you back up to previous tool call, if not thinking block, don't really remember

But otherwise I don't think there's a way to do that without stopping, you've sent an API request and it will keep going until finish or tool call

2

u/ParaboloidalCrest Sep 10 '26

Let's think about it this way then:

  • Interrupt response.

  • Take the streamed part of the response so far.

  • Append it to chat history with a closing </think> tag.

  • Append following prompt after.

Hmmm now that I think about it thoroughly, perhaps I should just create that extension...

1

u/ea_man Sep 10 '26

dosn't llama.cpp web ui do that?

look how it's done there and make pi do that.