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,
)
| 272 | |
| 273 | |
| 274 | def 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 | |
| 312 | async def handle_get_agent_state( |
no test coverage detected
searching dependent graphs…