Skip to content

fix(tools): add defensive type coercion in todo_tool for malformed LLM input#14785

Open
Tranquil-Flow wants to merge 2 commits into
NousResearch:mainfrom
Tranquil-Flow:fix/todo-tool-type-coercion
Open

fix(tools): add defensive type coercion in todo_tool for malformed LLM input#14785
Tranquil-Flow wants to merge 2 commits into
NousResearch:mainfrom
Tranquil-Flow:fix/todo-tool-type-coercion

Conversation

@Tranquil-Flow

@Tranquil-Flow Tranquil-Flow commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds defensive type coercion in todo_tool.py for cases where LLMs emit todo items as JSON strings instead of dicts, causing AttributeError: 'str' object has no attribute 'get'.

Related Issue

Fixes #14185

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • tools/todo_tool.py: Added type coercion for malformed LLM input
  • tests/tools/test_todo_tool_type_coercion.py: 13 tests

How to Test

python -m pytest -o 'addopts=' tests/tools/test_todo_tool_type_coercion.py -v

Result: 13 passed.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 15 (Darwin 24.6.0), Python 3.14.2

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

python -m pytest -o 'addopts=' tests/tools/test_todo_tool_type_coercion.py -v
13 passed

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets labels Apr 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #14185 (issue) and #14187 (competing fix PR) — todo_tool crashes when LLM emits todos as JSON string instead of array.

@Tranquil-Flow Tranquil-Flow force-pushed the fix/todo-tool-type-coercion branch from fd35cbd to 62f44a1 Compare May 25, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

todo_tool: AttributeError 'str' object has no attribute 'get' when LLM emits todos as JSON string

2 participants