devchat-ai / devchat

Automate your dev tasks with AI-powered scripts, from your IDE's chat panel.
https://www.devchat.ai
Apache License 2.0
340 stars 39 forks source link

Issue with chat_json decorator in devchat causing PROMPT template variable mutation #354

Closed yangbobo2021 closed 4 months ago

yangbobo2021 commented 4 months ago

There seems to be an issue within the devchat's chat functionality, specifically with the chat_json decorator. When it's called multiple times, the PROMPT template variable undergoes an undesired mutation during execution. This mutation affects the outcome when the function is repeatedly invoked, leading to inconsistent behavior and potentially incorrect results.

Steps to reproduce:

  1. Set up a PROMPT template for use with the chat_json decorator in a devchat environment.
  2. Invoke a function decorated with chat_json multiple times that uses the PROMPT template.
  3. Observe that the content of PROMPT is changed after initial calls, affecting subsequent function calls.

Expected behavior: The PROMPT template variable should remain constant across multiple invocations of the decorated function, ensuring consistent functionality throughout.

Actual behavior: The PROMPT variable is mutated during the process, leading to inconsistencies and possibly incorrect operation of the decorated function across calls.

This issue significantly affects the reliability and predictability of using the devchat's chat feature with the chat_json decorator, especially in scenarios where function reusability is crucial. Any insights or fixes for this problem would be greatly appreciated.