fix: move VAD agent creation to RI communication agent
Previously, it was started in main, but it should use values negotiated by the RI communication agent. ref: N25B-356
This commit is contained in:
@@ -39,13 +39,11 @@ from control_backend.agents.communication import RICommunicationAgent
|
||||
# LLM Agents
|
||||
from control_backend.agents.llm import LLMAgent
|
||||
|
||||
# Perceive agents
|
||||
from control_backend.agents.perception import VADAgent
|
||||
|
||||
# Other backend imports
|
||||
from control_backend.api.v1.router import api_router
|
||||
from control_backend.core.config import settings
|
||||
from control_backend.logging import setup_logging
|
||||
from control_backend.schemas.program_status import PROGRAM_STATUS, ProgramStatus
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -95,6 +93,8 @@ async def lifespan(app: FastAPI):
|
||||
endpoints_pub_socket.connect(settings.zmq_settings.internal_pub_address)
|
||||
app.state.endpoints_pub_socket = endpoints_pub_socket
|
||||
|
||||
await endpoints_pub_socket.send_multipart([PROGRAM_STATUS, ProgramStatus.STARTING.value])
|
||||
|
||||
# --- Initialize Agents ---
|
||||
logger.info("Initializing and starting agents.")
|
||||
|
||||
@@ -132,10 +132,6 @@ async def lifespan(app: FastAPI):
|
||||
"name": settings.agent_settings.text_belief_extractor_name,
|
||||
},
|
||||
),
|
||||
"VADAgent": (
|
||||
VADAgent,
|
||||
{"audio_in_address": settings.zmq_settings.vad_agent_address, "audio_in_bind": False},
|
||||
),
|
||||
"ProgramManagerAgent": (
|
||||
BDIProgramManager,
|
||||
{
|
||||
@@ -146,32 +142,28 @@ async def lifespan(app: FastAPI):
|
||||
|
||||
agents = []
|
||||
|
||||
vad_agent = None
|
||||
|
||||
for name, (agent_class, kwargs) in agents_to_start.items():
|
||||
try:
|
||||
logger.debug("Starting agent: %s", name)
|
||||
agent_instance = agent_class(**kwargs)
|
||||
await agent_instance.start()
|
||||
if isinstance(agent_instance, VADAgent):
|
||||
vad_agent = agent_instance
|
||||
agents.append(agent_instance)
|
||||
logger.info("Agent '%s' started successfully.", name)
|
||||
except Exception as e:
|
||||
logger.error("Failed to start agent '%s': %s", name, e, exc_info=True)
|
||||
raise
|
||||
|
||||
assert vad_agent is not None
|
||||
await vad_agent.reset_stream()
|
||||
|
||||
logger.info("Application startup complete.")
|
||||
|
||||
await endpoints_pub_socket.send_multipart([PROGRAM_STATUS, ProgramStatus.RUNNING.value])
|
||||
|
||||
yield
|
||||
|
||||
# --- APPLICATION SHUTDOWN ---
|
||||
logger.info("%s is shutting down.", app.title)
|
||||
|
||||
# Potential shutdown logic goes here
|
||||
await endpoints_pub_socket.send_multipart([PROGRAM_STATUS, ProgramStatus.STOPPING.value])
|
||||
# Additional shutdown logic goes here
|
||||
|
||||
logger.info("Application shutdown complete.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user