MCPcopy Create free account
hub / github.com/InternScience/InternAgent / __init__

Method __init__

internagent/mas/interface.py:34–86  ·  view source on GitHub ↗

Initialize the InternAgent interface. Args: config_path: Path to the configuration file config: Configuration dictionary (takes precedence over config_path) work_dir: Working directory for the system task_name: Name of the task (from

(self, config_path: str = None, config: Dict[str, Any] = None, work_dir: str = 'example', task_name: str = None, exp_backend: str = None)

Source from the content-addressed store, hash-verified

32 """
33
34 def __init__(self, config_path: str = None, config: Dict[str, Any] = None, work_dir: str = 'example', task_name: str = None, exp_backend: str = None):
35 """
36 Initialize the InternAgent interface.
37
38 Args:
39 config_path: Path to the configuration file
40 config: Configuration dictionary (takes precedence over config_path)
41 work_dir: Working directory for the system
42 task_name: Name of the task (from --task parameter)
43 exp_backend: Experiment backend to use (claudecode, iflow)
44 """
45 self.work_dir = work_dir
46 self.task_name = task_name or "DefaultTask"
47 self.config = self._load_config(config_path, config)
48 self.config['config_path'] = config_path
49 self.config['work_dir'] = self.work_dir
50 self.config['task_name'] = self.task_name
51 # Store exp_backend in config so agents can access it
52 if exp_backend:
53 self.config['exp_backend'] = exp_backend
54
55 # Core components
56 self.model_factory = ModelFactory()
57 self.memory_manager = self._init_memory_manager()
58 self.agent_factory = AgentFactory()
59
60 # Store tools configuration for later initialization
61 self.sci_tools = self.config.get("sci_tools", {})
62
63 # Initialize local function-based tools if enabled (synchronous)
64 if self.sci_tools.get("local", True): # Default to True for backward compatibility
65 logger.info("Loading local function-based tools...")
66 init_tools()
67 logger.info("Local tools initialized")
68 else:
69 logger.info("Local tools disabled by configuration")
70
71 # Create specialized agents
72 self.agents = self.agent_factory.create_all_agents(
73 config=self.config,
74 model_factory=self.model_factory
75 )
76
77 # Initialize orchestration agent
78 self.orchestration_agent = self._init_orchestration_agent()
79
80 # Session tracking
81 self.active_sessions = {}
82
83 # System state
84 self.system_ready = False
85
86 logger.info("InternAgent interface initialized")
87
88 async def startup(self) -> None:
89 """Initialize system components and mark as ready."""

Callers

nothing calls this directly

Calls 8

_load_configMethod · 0.95
_init_memory_managerMethod · 0.95
AgentFactoryClass · 0.85
init_toolsFunction · 0.85
create_all_agentsMethod · 0.80
ModelFactoryClass · 0.50
getMethod · 0.45

Tested by

no test coverage detected