From one tool to four

Modules 01 and 02 only have a bash tool. That means the model writes files with echo or cat heredocs, reads files with cat, and edits with sed. This works, but it's fragile because sed regexes for multi-line edits are error-prone and the model wastes tokens on shell escaping. Dedicated tools are more reliable and cheaper.

Matching exercise: Bash vs dedicated tools

Loading practice…

03-tool-design/agent.py (tool definitions)
python
TOOLS = [
    {"type": "function", "function": {
        "name": "read_file",
        "description": "Read file contents.",
        "parameters": {
            "type": "object",
            "properties": {
                "path": {"type": "string"},
                "limit": {"type": "integer"}
            },
            "required": ["path"]
        }
    }},
    # write_file, edit_file, bash follow the same pattern
]

Each tool is a JSON schema the model understands. Clear names, typed parameters, required fields.