@@ -447,10 +447,26 @@ async def _create_llm_agent(
447447 self , agent : Agent , processed_agents : set = None , enabled_tools : List [str ] = []
448448 ) -> Tuple [LlmAgent , Optional [List [str ]]]:
449449 """Create an LLM agent from the agent data."""
450+ # Merge integrations from the dedicated `agent_integrations` table into
451+ # the in-memory agent.config so native tools (ElevenLabs, Knowledge Nexus,
452+ # Google Calendar, Google Sheets) gated by `integrations[*].connected`
453+ # also pick up config rows persisted via POST /agents/:id/integrations.
454+ # Existing entries in agent.config["integrations"] take precedence.
455+ merged_config = dict (agent .config ) if agent .config else {}
456+ existing_integrations = dict (merged_config .get ("integrations" ) or {})
457+ for item in getattr (agent , "_integrations" , []) or []:
458+ provider = (item .get ("provider" ) or "" ).replace ("_" , "-" )
459+ if not provider :
460+ continue
461+ row_config = dict (item .get ("config" ) or {})
462+ row_config .setdefault ("connected" , True )
463+ existing_integrations .setdefault (provider , row_config )
464+ merged_config ["integrations" ] = existing_integrations
465+
450466 # Get custom tools from the configuration
451467 custom_tools = []
452468 custom_tools = self .tool_builder .build_tools (
453- agent . config , self .db , str (agent .id )
469+ merged_config , self .db , str (agent .id )
454470 )
455471
456472 # Get MCP tools from the configuration
0 commit comments