CortexAgent is the orchestration layer between CortexUI and CortexLTM.
The runtime is intentionally LLM-first and split into explicit layers:
planner(cortexagent/services/planner.py)- Reads full conversation context.
- Outputs a strict structured decision:
direct_responsetool_pipeline(ordered tool steps + args)
executor(cortexagent/services/executor.py)- Deterministically executes planner steps.
- Never infers intent or mutates plan decisions.
tool registry(cortexagent/tools/registry.py)- Holds tool schema + metadata.
- Validates planner args before execution.
orchestrator(cortexagent/services/orchestrator.py)- Coordinates planner + executor + persistence.
api(cortexagent/main.py)- FastAPI routes consumed by CortexUI.
No regex-based routing or keyword intent triggers are used for planner decisions.
The agent response keeps legacy fields expected by CortexUI:
decisiontool_pipelinesources
CortexUI still receives:
x-cortex-agent-tracex-cortex-route-mode
through the existing proxy behavior in CortexUI.
Google account connect/disconnect/status routes are provided:
POST /v1/agent/integrations/google/connectGET /v1/agent/integrations/google/statusPOST /v1/agent/integrations/google/disconnect
Google tool adapters retained:
- Calendar:
cortexagent/tools/google_calendar.py - Drive:
cortexagent/tools/google_drive.py - Gmail:
cortexagent/tools/google_gmail.py
POST /v1/agent/threads/{thread_id}/chat
Response model:
{
"thread_id": "string",
"response": "assistant text",
"decision": {
"action": "chat|orchestration|<tool_name>",
"reason": "planner rationale",
"confidence": 0.0
},
"sources": [{"title": "string", "url": "string"}],
"tool_pipeline": []
}Required:
CORTEXLTM_API_BASE_URLAGENT_PLANNER_LLM_PROVIDERAGENT_PLANNER_LLM_MODELAGENT_PLANNER_LLM_API_KEY(orGROQ_API_KEY)
Optional:
CORTEXLTM_API_KEYAGENT_PLANNER_LLM_TIMEOUT_SECONDS(default8)AGENT_PLANNER_MAX_STEPS(default4)AGENT_PLANNER_CONTEXT_MESSAGES(default10)AGENT_PLANNER_LLM_API_BASE_URLAGENT_SYNTHESIS_LLM_ENABLED(defaulttrue)AGENT_SYNTHESIS_LLM_PROVIDERAGENT_SYNTHESIS_LLM_MODELAGENT_SYNTHESIS_LLM_TIMEOUT_SECONDS(default10)AGENT_SYNTHESIS_LLM_API_BASE_URLAGENT_SYNTHESIS_LLM_API_KEY
Connected account / OAuth:
SUPABASE_URLSUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEYCONNECTED_ACCOUNTS_TABLE(defaultltm_connected_accounts)CONNECTED_ACCOUNTS_TIMEOUT_SECONDS(default8)CONNECTED_ACCOUNTS_TOKEN_ENCRYPTION_KEY(recommended)GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETGOOGLE_REDIRECT_URIGOOGLE_OAUTH_TIMEOUT_SECONDS(default8)
uvicorn cortexagent.main:app --host 0.0.0.0 --port 8010