Skip to content

agent.chat() Fails to Reset Code Context (State Residue) #1855

@Almo2512

Description

@Almo2512

System Info

The agent.chat() method fails to fully reset the session state, leading to the previously executed code (last_code_generated) persisting in the new prompt. This contradicts the "clean start" expected from the chat() method. when i call the method clear memorty, it dose not delete everythin, because these method never delete their value: @Property
def last_generated_code(self):
return self._state.last_code_generated

@property
def last_code_executed(self):
    return self._state.last_code_generated

@property
def last_prompt_used(self):
    return self._state.last_prompt_used

🐛 Describe the bug

def clear_memory(self):
"""
Clears the memory
"""
self._state.memory.clear()

it should be like this:

def start_new_conversation(self):
self.clear_memory()

# Add explicit code context reset:
if hasattr(self._state, 'last_code_generated'):
    self._state.last_code_generated = None
if hasattr(self._state, 'last_prompt_used'):
    self._state.last_prompt_used = None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions