Skip to content

Commit ec52231

Browse files
fix: resolve backend variable shadowing in Agent initialization
The issue was caused by a local variable 'backend' in the memory configuration processing that was shadowing the 'backend' parameter from the Agent constructor. When memory=True was passed to the Agent, the memory backend string (e.g., 'file') was incorrectly assigned to self.backend instead of the external managed backend. This caused a RuntimeError: Backend str does not support execute() method when the Agent tried to delegate to what it thought was a managed backend but was actually a string. Changes: - Rename local variable from 'backend' to 'memory_backend' to avoid shadowing - Preserves the original backend parameter functionality - Fixes the issue where memory=True would break external backend delegation Fixes #1371 Co-authored-by: praisonai-triage-agent[bot] <praisonai-triage-agent[bot]@users.noreply.github.com>
1 parent 81dfb6a commit ec52231

File tree

1 file changed

+5
-5
lines changed
  • src/praisonai-agents/praisonaiagents/agent

1 file changed

+5
-5
lines changed

src/praisonai-agents/praisonaiagents/agent/agent.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,18 +1042,18 @@ def __init__(
10421042
if _memory_config.auto_save is not None:
10431043
auto_save = _memory_config.auto_save
10441044
# Convert to internal format
1045-
backend = _memory_config.backend
1046-
if hasattr(backend, 'value'):
1047-
backend = backend.value
1045+
memory_backend = _memory_config.backend
1046+
if hasattr(memory_backend, 'value'):
1047+
memory_backend = memory_backend.value
10481048
# If learn is enabled, pass as dict to trigger full Memory class
10491049
if _memory_config.learn:
10501050
memory = _memory_config.to_dict()
1051-
elif backend == "file":
1051+
elif memory_backend == "file":
10521052
memory = True
10531053
elif _memory_config.config:
10541054
memory = _memory_config.config
10551055
else:
1056-
memory = backend
1056+
memory = memory_backend
10571057
elif hasattr(_memory_config, 'search') and hasattr(_memory_config, 'add'):
10581058
# Memory instance - pass through
10591059
pass

0 commit comments

Comments
 (0)