r2ai icon indicating copy to clipboard operation
r2ai copied to clipboard

r2ai C resets context between each direct request

Open cryptax opened this issue 7 months ago • 0 comments
trafficstars

I am using the C plugin in ./src. Lets suppose I begin a binary analysis with this:

r2ai -e api=mistral
r2ai -e model=codestral-latest
aaa
s main
r2ai -d

So, I issue a first request to the LLM using the default prompt. All good. Then, I decide to change my prompt:

r2ai -e prompt=Improve your code and rename variables, do not use register names as variables

And I issue another direct request:

r2ai -d

The context which is sent is the following. See that the user prompt has been entirely replaced.

model":"codestral-latest","stream":false,"temperature":0.010,"max_tokens":5128, "messages": [{"role":"system","content":"You are a reverse engineer. ..."},
{"role":"user","content":"Improve your code and rename variables, do not use register names as variables"}
...

We'd expect this second request to have:

  • the first prompt
  • the contents of pdc
  • the second prompt

If you wish to have a mode that automatically resets the context in between each query, I suggest that there is an option like r2ai.direct.automatic_context_rest=true. Or the other way round if you prefer r2ai.direct.keep_context=true.

Anyway, it's surprising to the end-user that the context is reset, especially as there is r2ai -R to reset the context...

cryptax avatar Apr 15 '25 15:04 cryptax