diff --git a/agixt/Agent.py b/agixt/Agent.py index c39ae4c554b8..6c84ad9529ca 100644 --- a/agixt/Agent.py +++ b/agixt/Agent.py @@ -232,6 +232,17 @@ def get_agents(user=DEFAULT_USER, company=None): if company_id and company: if company_id != company: continue + if not company_id: + auth = MagicalAuth(token=impersonate_user(user_id=str(user_data.id))) + company_id = str(auth.company_id) + # update agent settings + agent_setting = AgentSettingModel( + agent_id=agent.id, + name="company_id", + value=company_id, + ) + session.add(agent_setting) + session.commit() output.append( { "name": agent.name,