todo: migrate tool output to structured JSON schemas#2045
todo: migrate tool output to structured JSON schemas#2045dgageot wants to merge 1 commit intodocker:mainfrom
Conversation
Replace plain-text string output with proper JSON-structured responses for all todo tools. Each tool now has a typed OutputSchema matching its actual output: - create_todo: returns a Todo object - create_todos: returns CreateTodosOutput with created []Todo - update_todos: returns UpdateTodosOutput with updated/not_found - list_todos: returns ListTodosOutput with todos []Todo Extract addTodo and jsonResult helpers to reduce duplication. Fix jsonschema descriptions for consistency. Assisted-By: docker-agent
There was a problem hiding this comment.
🔍 cagent Review
Assessment: 🟢 APPROVE
The refactoring successfully migrates todo tool output to structured JSON schemas with proper error handling and helper function extraction. No critical or high-severity bugs were found.
One minor design inconsistency was noted for consideration:
Optional Improvement
While not blocking, there's a pattern inconsistency in the output structure design:
createTodo returns bare Todo while other tools use wrapper types
createTodoreturns:TododirectlycreateTodosreturns:CreateTodosOutput{Created: []Todo}updateTodosreturns:UpdateTodosOutput{...}listTodosreturns:ListTodosOutput{...}
Since this PR explicitly aims for "proper JSON-structured responses," consider wrapping createTodo's output in a dedicated type (e.g., CreateTodoOutput{Todo: Todo}) for consistency with the other tools.
The current implementation works correctly and tests pass—this is purely about maintaining a consistent pattern across all tool outputs.
| }) | ||
| } | ||
| func (h *todoHandler) createTodo(_ context.Context, params CreateTodoArgs) (*tools.ToolCallResult, error) { | ||
| return h.jsonResult(h.addTodo(params.Description)) |
There was a problem hiding this comment.
Optional Improvement: Output Structure Consistency
The createTodo function returns a bare Todo object, while all other tools wrap their outputs in dedicated types:
- ✅
createTodos→CreateTodosOutput{Created: []Todo} - ✅
updateTodos→UpdateTodosOutput{...} - ✅
listTodos→ListTodosOutput{...} ⚠️ createTodo→Todo(bare object)
Since this PR explicitly refactors for "proper JSON-structured responses," consider wrapping this output in a dedicated type (e.g., CreateTodoOutput{Todo: Todo}) for consistency.
Not blocking—the current implementation works correctly.
Replace plain-text string output with proper JSON-structured responses for all todo tools. Each tool now has a typed
OutputSchemamatching its actual output:create_todo: returns aTodoobjectcreate_todos: returnsCreateTodosOutputwithcreated []Todoupdate_todos: returnsUpdateTodosOutputwithupdated/not_foundlist_todos: returnsListTodosOutputwithtodos []TodoOther improvements
addTodohelper to deduplicate todo creation logicjsonResulthelper to deduplicate JSON marshaling +ToolCallResultconstructionTodotype ascreate_todooutput (eliminates redundantCreateTodoOutputstruct)jsonschemadescriptions for consistency ("New status" → "Status of the todo item", add missing space)updateTodoserror path to reusejsonResultinstead of duplicating marshal logicrequireMetatest helper to reduce assertion boilerplate