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:
pythonprint("Hello World")
Task: add a greet(name) function while preserving the existing greeting. The intended finished artifact is:
pythondef 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
textlist 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:
pythonfrom 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.