Fixed project activation in process-isolated agent

This commit is contained in:
Michael Panchenko committed 2025-06-16 02:40:04 +02:00
1 parent beb6b4e67d
commit 3d4892394a
3 files changed
+7 -5

No files matched your search

-3
View File
@@ -569,7 +569,6 @@ class MemoriesManagerMDFilesInProject(MemoriesManager):
def create_serena_config(
project: str | None = None,
serena_config: SerenaConfigBase | None = None,
context: SerenaAgentContext | None = None,
modes: list[SerenaAgentMode] | None = None,
@@ -585,7 +584,6 @@ def create_serena_config(
This function extracts the configuration creation logic from SerenaAgent.__init__
to allow creating configurations independently for process isolation and other use cases.
:param project: the project to register/activate or None
:param serena_config: the base Serena configuration or None to read from default location
:param context: the context in which the agent will operate
:param modes: list of modes in which the agent will operate
@@ -670,7 +668,6 @@ class SerenaAgent:
"""
# obtain serena configuration using the decoupled factory function
self.serena_config = create_serena_config(
project=None, # Don't pass project here, handle activation separately
serena_config=serena_config,
context=context,
modes=modes,
+4 -2
View File
@@ -137,9 +137,11 @@ def create_mcp_server_and_agent(
context_instance = SerenaAgentContext.load(context)
modes_instances = [SerenaAgentMode.load(mode) for mode in modes]
if project is not None:
log.info(f"Will use project at mcp server startup: {project}")
try:
serena_config = create_serena_config(
project=project,
context=context_instance,
modes=modes_instances,
enable_web_dashboard=enable_web_dashboard,
@@ -148,7 +150,7 @@ def create_mcp_server_and_agent(
trace_lsp_communication=trace_lsp_communication,
tool_timeout=tool_timeout,
)
serena_agent_process = ProcessIsolatedSerenaAgent(serena_config=serena_config)
serena_agent_process = ProcessIsolatedSerenaAgent(project=project, serena_config=serena_config)
# Start process-isolated dashboard if enabled
serena_dashboard_process = None
+3
View File
@@ -436,6 +436,7 @@ class ProcessIsolatedSerenaAgent:
# Use the default config loader
self.serena_config = SerenaConfig.from_config_file()
self.process: multiprocessing.Process | None = None
self.project = project
self.conn: Connection | None = None
def start(self) -> None:
@@ -456,12 +457,14 @@ class ProcessIsolatedSerenaAgent:
# Initialize the agent in the worker process
try:
# TODO: instead pass config and project to worker, use at startup of agent there
# Prepare initialization parameters, converting complex objects to dict if present
init_params = self._init_params.copy()
if init_params["serena_config"] is not None and hasattr(init_params["serena_config"], "to_dict"):
# Convert SerenaConfigBase to dict for serialization
serena_config_obj = init_params["serena_config"]
init_params["serena_config"] = serena_config_obj.to_dict() # type: ignore
# init_params["project"] = self.project
# Note: context and modes are not serializable across processes,
# so they will be None and SerenaAgent will use defaults
init_params["context"] = None