MCPcopy
hub / github.com/CopilotKit/CopilotKit / handle_execute_agent

Function handle_execute_agent

sdk-python/copilotkit/integrations/fastapi.py:274–309  ·  view source on GitHub ↗

Handle continue agent execution request with FastAPI

(  # pylint: disable=too-many-arguments
    *,
    sdk: CopilotKitRemoteEndpoint,
    context: CopilotKitContext,
    thread_id: str,
    name: str,
    state: dict,
    config: Optional[dict] = None,
    messages: List[Message],
    actions: List[ActionDict],
    node_name: str,
    meta_events: Optional[List[MetaEvent]] = None,
)

Source from the content-addressed store, hash-verified

272
273
274def handle_execute_agent( # pylint: disable=too-many-arguments
275 *,
276 sdk: CopilotKitRemoteEndpoint,
277 context: CopilotKitContext,
278 thread_id: str,
279 name: str,
280 state: dict,
281 config: Optional[dict] = None,
282 messages: List[Message],
283 actions: List[ActionDict],
284 node_name: str,
285 meta_events: Optional[List[MetaEvent]] = None,
286):
287 """Handle continue agent execution request with FastAPI"""
288 try:
289 events = sdk.execute_agent(
290 context=context,
291 thread_id=thread_id,
292 name=name,
293 node_name=node_name,
294 state=state,
295 config=config,
296 messages=messages,
297 actions=actions,
298 meta_events=meta_events,
299 )
300 return StreamingResponse(events, media_type="application/json")
301 except AgentNotFoundException as exc:
302 logger.error("Agent not found: %s", exc, exc_info=True)
303 return JSONResponse(content={"error": str(exc)}, status_code=404)
304 except AgentExecutionException as exc:
305 logger.error("Agent execution error: %s", exc, exc_info=True)
306 return JSONResponse(content={"error": str(exc)}, status_code=500)
307 except Exception as exc: # pylint: disable=broad-except
308 logger.error("Agent execution error: %s", exc, exc_info=True)
309 return JSONResponse(content={"error": str(exc)}, status_code=500)
310
311
312async def handle_get_agent_state(

Callers 2

handlerFunction · 0.85
handler_v1Function · 0.85

Calls 3

strFunction · 0.85
execute_agentMethod · 0.80
errorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…