MCPcopy Create free account
hub / github.com/SkyworkAI/DeepResearchAgent / get_variables

Method get_variables

src/memory/context.py:1004–1050  ·  view source on GitHub ↗

Get variables from memory systems, where each memory's code is used as the variable value. Args: memory_name (Optional[str]): Name of a specific memory system. If None, returns variables for all memory systems. Returns: Dict[str, Variable

(self, memory_name: Optional[str] = None)

Source from the content-addressed store, hash-verified

1002 return restored_config
1003
1004 async def get_variables(self, memory_name: Optional[str] = None) -> Dict[str, 'Variable']:
1005 """Get variables from memory systems, where each memory's code is used as the variable value.
1006
1007 Args:
1008 memory_name (Optional[str]): Name of a specific memory system. If None, returns variables for all memory systems.
1009
1010 Returns:
1011 Dict[str, Variable]: Dictionary mapping memory names to Variable objects. Each Variable has:
1012 - name: memory name
1013 - type: "memory_code"
1014 - description: memory description
1015 - require_grad: memory's require_grad value
1016 - variables: memory's code (as string value)
1017 """
1018 # Lazy import to avoid circular dependency
1019 from src.optimizer.types import Variable
1020
1021 variables: Dict[str, Variable] = {}
1022
1023 if memory_name is not None:
1024 # Get specific memory
1025 memory_config = self._memory_configs.get(memory_name)
1026 if memory_config is None:
1027 logger.warning(f"| ⚠️ Memory {memory_name} not found")
1028 return variables
1029
1030 memory_configs = {memory_name: memory_config}
1031 else:
1032 # Get all memory systems
1033 memory_configs = self._memory_configs
1034
1035 for name, memory_config in memory_configs.items():
1036 # Get memory code
1037 memory_code = memory_config.code or ""
1038
1039 # Create Variable for this memory system
1040 variable = Variable(
1041 name=name,
1042 type="memory_code",
1043 description=memory_config.description or f"Code for memory system {name}",
1044 require_grad=memory_config.require_grad,
1045 template=None,
1046 variables=memory_code # Store code as the variable value
1047 )
1048 variables[name] = variable
1049
1050 return variables
1051
1052 async def get_trainable_variables(self, memory_name: Optional[str] = None) -> Dict[str, 'Variable']:
1053 """Get trainable variables from memory systems, filtering out memory systems with require_grad=False.

Callers 1

Calls 3

VariableClass · 0.90
warningMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected