Respond to a DeepCode User-in-Loop interaction request.
| 386 | |
| 387 | |
| 388 | class DeepCodeRespondTool(Tool): |
| 389 | """Respond to a DeepCode User-in-Loop interaction request.""" |
| 390 | |
| 391 | def __init__(self, api_url: str | None = None): |
| 392 | self._api_url = api_url or _get_deepcode_url() |
| 393 | |
| 394 | @property |
| 395 | def name(self) -> str: |
| 396 | return "deepcode_respond" |
| 397 | |
| 398 | @property |
| 399 | def description(self) -> str: |
| 400 | return ( |
| 401 | "Respond to a DeepCode User-in-Loop interaction. " |
| 402 | "When a DeepCode task is waiting for user input (e.g. requirement clarification, " |
| 403 | "plan review), use this tool to submit the user's response. " |
| 404 | "First check deepcode_status to see the pending interaction details." |
| 405 | ) |
| 406 | |
| 407 | @property |
| 408 | def parameters(self) -> dict[str, Any]: |
| 409 | return { |
| 410 | "type": "object", |
| 411 | "properties": { |
| 412 | "task_id": { |
| 413 | "type": "string", |
| 414 | "description": "The task ID that is waiting for input", |
| 415 | }, |
| 416 | "action": { |
| 417 | "type": "string", |
| 418 | "enum": ["submit", "confirm", "modify", "skip", "cancel"], |
| 419 | "description": "User's action: submit answers, confirm plan, modify, skip, or cancel", |
| 420 | }, |
| 421 | "data": { |
| 422 | "type": "object", |
| 423 | "description": "Response data (e.g. answers to questions, modification feedback)", |
| 424 | }, |
| 425 | "skipped": { |
| 426 | "type": "boolean", |
| 427 | "description": "Whether the user chose to skip this interaction. Default: false", |
| 428 | }, |
| 429 | }, |
| 430 | "required": ["task_id", "action"], |
| 431 | } |
| 432 | |
| 433 | async def execute( |
| 434 | self, |
| 435 | task_id: str, |
| 436 | action: str, |
| 437 | data: dict | None = None, |
| 438 | skipped: bool = False, |
| 439 | **kwargs: Any, |
| 440 | ) -> str: |
| 441 | try: |
| 442 | async with httpx.AsyncClient(timeout=30.0) as client: |
| 443 | response = await client.post( |
| 444 | f"{self._api_url}/api/v1/workflows/respond/{task_id}", |
| 445 | json={ |