MCPcopy Index your code
hub / github.com/agent0ai/agent-zero / initialize_agent

Function initialize_agent

initialize.py:7–47  ·  view source on GitHub ↗
(override_settings: dict | None = None)

Source from the content-addressed store, hash-verified

5
6@extension.extensible
7def initialize_agent(override_settings: dict | None = None):
8 current_settings = settings.get_settings()
9 if override_settings:
10 current_settings = settings.merge_settings(current_settings, override_settings)
11
12 # agent configuration - models are now resolved at call time via _model_config plugin
13 config = AgentConfig(
14 profile=current_settings["agent_profile"],
15 knowledge_subdirs=[current_settings["agent_knowledge_subdir"], "default"],
16 mcp_servers=current_settings["mcp_servers"],
17 )
18
19 # update config with runtime args
20 _args_override(config)
21
22 # initialize MCP in deferred task to prevent blocking the main thread
23 # async def initialize_mcp_async(mcp_servers_config: str):
24 # return initialize_mcp(mcp_servers_config)
25 # defer.DeferredTask(thread_name="mcp-initializer").start_task(initialize_mcp_async, config.mcp_servers)
26 # initialize_mcp(config.mcp_servers)
27
28 # import helpers.mcp_handler as mcp_helper
29 # import agent as agent_helper
30 # import helpers.print_style as print_style_helper
31 # if not mcp_helper.MCPConfig.get_instance().is_initialized():
32 # try:
33 # mcp_helper.MCPConfig.update(config.mcp_servers)
34 # except Exception as e:
35 # first_context = agent_helper.AgentContext.first()
36 # if first_context:
37 # (
38 # first_context.log
39 # .log(type="warning", content=f"Failed to update MCP settings: {e}")
40 # )
41 # (
42 # print_style_helper.PrintStyle(background_color="black", font_color="red", padding=True)
43 # .print(f"Failed to update MCP settings: {e}")
44 # )
45
46 # return config object
47 return config
48
49@extension.extensible
50def initialize_chats():

Callers 15

executeMethod · 0.90
use_contextFunction · 0.90
__new_contextMethod · 0.90
_deserialize_contextFunction · 0.90
run_taskMethod · 0.90
_handle_agentFunction · 0.90
_apply_settingsFunction · 0.90
send_messageFunction · 0.90

Calls 2

AgentConfigClass · 0.90
_args_overrideFunction · 0.85