MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / agents

Function agents

app/api/agentops/api/routes/v1.py:88–123  ·  view source on GitHub ↗
(request: Request, supabase: AsyncSupabaseClient)

Source from the content-addressed store, hash-verified

86
87@router.post("/agents")
88async def agents(request: Request, supabase: AsyncSupabaseClient):
89 try:
90 api_key = request.headers.get("X-Agentops-Auth")
91
92 sessions, data = await asyncio.gather(
93 supabase.table("sessions").select("id").eq("api_key", api_key).limit(1).single().execute(),
94 request.json(),
95 )
96
97 session_ids = [session["id"] for session in sessions]
98 if data["session_id"] not in session_ids:
99 raise RuntimeError("Invalid API Key for Session")
100
101 logger.debug(data)
102
103 except RuntimeError as e:
104 message = {"message": f"/agents: Error creating agent: {e}"}
105 logger.error(message)
106 return JSONResponse(message, status_code=401)
107
108 try:
109 agent = {
110 "id": data["id"],
111 "session_id": data["session_id"],
112 "name": data.get("name", None),
113 "logs": data.get("logs", None),
114 }
115
116 await supabase.table("agents").upsert(agent).execute()
117
118 logger.info(f"/agents: Completed POST request for {agent['id']}")
119 return JSONResponse("Success")
120 except RuntimeError as e:
121 message = {"message": f"/agents: Error creating agent: {e}"}
122 logger.error(message)
123 return JSONResponse(message, status_code=400)
124
125
126@router.post("/threads")

Callers

nothing calls this directly

Calls 4

jsonMethod · 0.80
upsertMethod · 0.80
getMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…