Summary
Introduced a ToolCallRegistry as the single source of truth for tool call lifecycle data and migrated session todos to typed TodoItem storage with explicit serialization. This removes duplicated tool call tracking and aligns runtime todo state with canonical types.
Context
Tool calls were tracked in separate runtime lists and arg caches, while todos were stored as ad-hoc dicts. Both patterns increased drift risk and made lifecycle semantics inconsistent across the session.
Changes
- Tool registry: Added
ToolCallRegistryand wired tool dispatch, tool execution failure tracking, and tool return completion updates to the registry. - Runtime state: Removed
tool_callsandtool_call_args_by_id, replacing them withruntime.tool_registry. - Todo alignment: Stored todos as
TodoIteminstances, updated todo tools to emit typed items, and normalized session serialization/deserialization. - Docs: Refreshed codebase-map and refactor docs to reflect registry ownership and typed todos.
Behavioral Impact
What users notice:
- Tool lifecycle data is consistent across executions and JSON export paths.
- Todo state is typed and validated consistently in todowrite/todoread.
What didn't change:
- Tool execution flow and message history semantics remain the same.
- Legacy session files still load via dict-to-TodoItem conversion.
Related Cards
- [[orphaned-retry-prompt-dangling-cleanup]]