Skip to content

Conversation

@LJlkdskdjflsa
Copy link

Summary

  • Consolidate duplicate write_todos tool definitions into a single factory function _create_write_todos_tool()
  • Eliminate code duplication between the module-level tool and the one created inside TodoListMiddleware.__init__
  • The factory function accepts a description parameter, enabling customization while maintaining a single source of truth

Why

The write_todos tool was defined twice:

  1. At module level (line 118-126) - used for direct imports and testing
  2. Inside TodoListMiddleware.__init__ (line 174-186) - to support custom tool_description

This duplication could lead to inconsistencies if one definition is updated but not the other.

Test plan

  • All existing unit tests pass (pytest tests/unit_tests/agents/middleware/implementations/test_todo.py)
  • No changes to public API - write_todos and TodoListMiddleware work exactly as before

🤖 Generated with Claude Code

@github-actions github-actions bot added langchain `langchain` package issues & PRs refactor PRs that include a refactor labels Dec 16, 2025
@LJlkdskdjflsa LJlkdskdjflsa force-pushed the refactor/todo-middleware-factory-function branch from 1922e60 to 2c590e5 Compare December 16, 2025 09:22
Consolidate duplicate `write_todos` tool definitions into a single factory
function `_create_write_todos_tool()`. This eliminates code duplication
between the module-level tool and the one created inside
`TodoListMiddleware.__init__`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@LJlkdskdjflsa LJlkdskdjflsa force-pushed the refactor/todo-middleware-factory-function branch from 2c590e5 to a562495 Compare December 16, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

langchain `langchain` package issues & PRs refactor PRs that include a refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant