匠人学院 JR Academy
Skip to article
Engineering handbook
AI Agent Engineering Handbook

Start with tool calls. Understand how an agent acts, reads observations and stops when something fails. Verify each boundary with complete code and offline tests.

5 chapters·16 guides·Open access
Exercise 3: Mini-Coder
On this page

Lab: Mini-Coder, a Small Coding Agent

A coding agent should inspect actual files, propose a change and verify the resulting artifact. Printing “done” without a diff or a check is not a completed coding task.

#Use an isolated sample workspace

The fictional starting file is:

python
print("Hello World")

Task: add a greet(name) function while preserving the existing greeting. The intended finished artifact is:

python
def greet(name): return f"Hello {name}" if __name__ == "__main__": print("Hello World")

Both snippets are teaching fixtures, not a transcript of an autonomous agent execution.

#Define narrow tools

Provide file listing, bounded file reading and patch proposal tools. Resolve paths under the approved workspace and reject traversal or symlinks that escape it. Do not give the model unrestricted filesystem or shell access.

Prefer a patch against the version the agent actually read. Before applying, check that the file has not changed. Direct whole-file replacement is easy to demonstrate but can overwrite unrelated work.

#Follow a verifiable sequence

text
list files -> read hello.py -> propose diff -> review/apply within scope -> run syntax check -> run behavior assertions -> inspect final diff

A minimal local assertion after saving the intended file is:

python
from hello import greet assert greet("Alex") == "Hello Alex"

Importing should not print the original greeting, which is why the entry point has a main guard. Also run the script to verify that its original visible behavior remains.

#Add capabilities carefully

A filesystem MCP server can standardize tool access, but it is not automatically a sandbox. Review directory scope, server version and execution permissions. Run untrusted code in an appropriate isolated environment with network, time and resource limits.

Stop after a bounded number of repair attempts. Report the actual changed files, checks run and remaining failures; never convert an unexecuted test into a passing result.

System Design

Core system design concepts and practical case studies

Learn the trade-offs and patterns that matter in technical interviews.

Open System Design →

FAQ

Which language should I use?
Python and TypeScript both work. Start with the language you can debug; the first exercise uses Python 3.10+ and its standard library.
Does MCP require a specific model?
No. MCP connects applications to tools and context services. Compatibility depends on the host client, transport, protocol version and authorisation; model tool-calling support is a separate check.
Does learning agents guarantee employment?
No. Use a small project to demonstrate requirements analysis, permissions, testing and maintenance. Employment outcomes depend on the role market and your actual skills.

Done reading? Next steps