|
37 | 37 | ) |
38 | 38 |
|
39 | 39 | from idp_common.bedrock.client import CACHEPOINT_SUPPORTED_MODELS |
| 40 | +from idp_common.utils.strands_agent_tools.todo_list import ( |
| 41 | + create_todo_list, |
| 42 | + update_todo, |
| 43 | + view_todo_list, |
| 44 | +) |
40 | 45 |
|
41 | 46 | # Use AWS Lambda Powertools Logger for structured logging |
42 | 47 | # Automatically logs as JSON with Lambda context, request_id, timestamp, etc. |
@@ -404,77 +409,6 @@ def patch_buffer_data(patches: list[dict[str, Any]], agent: Agent) -> str: |
404 | 409 | return f"Successfully patched {str(patched_data)[100:]}...." |
405 | 410 |
|
406 | 411 |
|
407 | | -@tool |
408 | | -def create_todo_list(todos: list[str], agent: Agent) -> str: |
409 | | - """Create a new todo list to track your extraction tasks. Use this to plan your work, especially for large documents. |
410 | | -
|
411 | | - Args: |
412 | | - todos: List of task descriptions to track (e.g., ["Extract rows 1-100", "Extract rows 101-200"]) |
413 | | -
|
414 | | - Example: |
415 | | - create_todo_list(["Extract first 100 rows", "Extract rows 101-200", "Extract rows 201-300", "Validate and finalize"], agent) |
416 | | - """ |
417 | | - todo_list = [{"task": task, "completed": False} for task in todos] |
418 | | - agent.state.set("todo_list", todo_list) |
419 | | - logger.info("Created todo list", extra={"todo_count": len(todo_list)}) |
420 | | - return f"Created todo list with {len(todo_list)} tasks:\n" + "\n".join( |
421 | | - f"{i + 1}. [ ] {item['task']}" for i, item in enumerate(todo_list) |
422 | | - ) |
423 | | - |
424 | | - |
425 | | -@tool |
426 | | -def update_todo(task_index: int, completed: bool, agent: Agent) -> str: |
427 | | - """Mark a todo item as completed or not completed. |
428 | | -
|
429 | | - Args: |
430 | | - task_index: Index of the task to update (1-based, matching the list display) |
431 | | - completed: True to mark as completed, False to mark as incomplete |
432 | | -
|
433 | | - Example: |
434 | | - update_todo(1, True, agent) # Mark first task as completed |
435 | | - """ |
436 | | - todo_list: list[dict[str, Any]] | None = agent.state.get("todo_list") |
437 | | - |
438 | | - if not todo_list: |
439 | | - return "No todo list found. Create one first using create_todo_list." |
440 | | - |
441 | | - # Convert to 0-based index |
442 | | - index = task_index - 1 |
443 | | - |
444 | | - if index < 0 or index >= len(todo_list): |
445 | | - return f"Invalid task index {task_index}. Valid range: 1-{len(todo_list)}" |
446 | | - |
447 | | - todo_list[index]["completed"] = completed |
448 | | - agent.state.set("todo_list", todo_list) |
449 | | - |
450 | | - status = "completed" if completed else "incomplete" |
451 | | - logger.info( |
452 | | - f"Updated todo {task_index}", |
453 | | - extra={"task": todo_list[index]["task"], "completed": completed}, |
454 | | - ) |
455 | | - return f"Task {task_index} marked as {status}: {todo_list[index]['task']}" |
456 | | - |
457 | | - |
458 | | -@tool |
459 | | -def view_todo_list(agent: Agent) -> str: |
460 | | - """View your current todo list with completion status.""" |
461 | | - todo_list: list[dict[str, Any]] | None = agent.state.get("todo_list") |
462 | | - |
463 | | - if not todo_list: |
464 | | - return "No todo list found. Create one using create_todo_list to track your extraction tasks." |
465 | | - |
466 | | - completed_count = sum(1 for item in todo_list if item["completed"]) |
467 | | - total_count = len(todo_list) |
468 | | - |
469 | | - result = f"Todo List ({completed_count}/{total_count} completed):\n" |
470 | | - result += "\n".join( |
471 | | - f"{i + 1}. [{'✓' if item['completed'] else ' '}] {item['task']}" |
472 | | - for i, item in enumerate(todo_list) |
473 | | - ) |
474 | | - |
475 | | - return result |
476 | | - |
477 | | - |
478 | 412 | SYSTEM_PROMPT = """ |
479 | 413 | You are a useful assistant that helps turn unstructured data into structured data using the provided tools. |
480 | 414 |
|
|
0 commit comments