This repository is a hands-on workspace for building a minimal coding agent step by step.
- Learning plans live in docs/12-week-ai-agent-plan.md and docs/12-week-ai-agent-plan.zh-CN.md.
- Reusable application code lives in src/mini_coding_agent.
- Local practice repos and other disposable sandboxes live in sandbox.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtIf pip install fails on this machine with certificate verification errors, retry with:
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org -r requirements.txtCreate your local secrets file from .env.example, then fill in the provider and API key you want to use.
If you do not want to activate the virtual environment every time, use the project-local binaries directly:
.venv/bin/python -V
.venv/bin/pytest -qUse .env to choose the model provider:
LLM_PROVIDER=openai
OPENAI_API_KEY=
CEREBRAS_API_KEY=
MODEL_NAME=gpt-4.1-miniFor OpenAI:
LLM_PROVIDER=openai- fill in
OPENAI_API_KEY - set
MODEL_NAMEto an OpenAI model such asgpt-4.1-mini
For Cerebras:
LLM_PROVIDER=cerebras- fill in
CEREBRAS_API_KEY - set
MODEL_NAMEto a Cerebras-served model such asgpt-oss-120b
make chat-basic: send one minimal request through the configured model providermake example-run: run the local practice repomake example-test: run the practice repo tests
make chat-basic
make example-run
make example-testThe provider switch is implemented in llm_client.py. It uses the standard openai Python package for both OpenAI and Cerebras, and points Cerebras requests at https://api.cerebras.ai/v1.
The repository is currently at a clean "Week 1 foundation" stage:
- environment is set up with a project-local
.venv - provider switching between OpenAI and Cerebras works through one shared client
make chat-basicsends a real model requestsandbox/example_repo/gives you one small local repo for code-reading and testing practicemake example-testconfirms the sandbox repo is still behaving as expected
This means the project is ready for the next small capabilities:
- strict structured output
- one simple tool call
- the first minimal agent loop
make chat-basic currently flows like this:
MakefilerunsPYTHONPATH=src .venv/bin/python -m mini_coding_agent.chat_basic- chat_basic.py imports
create_client() - llm_client.py loads
.envand choosesopenaiorcerebras client.chat.completions.create(...)sends the actual API request- the script prints the active provider, model name, and model response
make example-run currently flows like this:
Makefilerunssandbox/example_repo/app.pyapp.pyimportsconfig.pyandgreetings.pybuild_greeting()returns the greeting text- the app prints the final message
AI-Learning/
├── README.md
├── Makefile
├── requirements.txt
├── docs/
│ ├── 12-week-ai-agent-plan.md
│ └── 12-week-ai-agent-plan.zh-CN.md
├── src/
│ └── mini_coding_agent/
│ ├── __init__.py
│ ├── chat_basic.py
│ └── llm_client.py
├── sandbox/
│ └── example_repo/
├── notes/
├── logs/
├── eval/
└── examples/
docs/: learning plans and long-form project notessrc/mini_coding_agent/: the reusable application code you are buildingsandbox/example_repo/: small practice repository for repo-reading and command tasksnotes/: weekly notes and retrospectiveslogs/: run logs and traceseval/: evaluation tasks and baselinesexamples/: reusable examples and patch cases
As you continue the 12-week plan, new reusable code should usually go under src/mini_coding_agent/.
- Week 1-2:
structured_output.py,single_tool.py,agent_loop.py,tools.py - Week 4-6:
repo_tools.py,command_runner.py,patch_generator.py - Week 7+:
main.py,tracing.py,context_manager.py,doc_retriever.py
Keep temporary practice targets, tiny broken repos, and throwaway experiments under sandbox/ rather than in the repository root.
If you want the most practical next sequence from the current state, do it in this order:
- Add
structured_output.pyand make one response conform to a fixed schema. - Add
single_tool.pywith one safe fake tool such asget_time. - Add
agent_loop.pythat can repeat until it gets either a final answer or a tool call. - Reuse
sandbox/example_repo/once you start adding repo-reading tools.
- If
make chat-basicfails with a missing key error, check.envand make sure the key matchesLLM_PROVIDER. - If
make chat-basicfails with authentication or401, your API key is wrong, expired, or tied to the wrong provider. - If
make chat-basicfails with a model error, check whetherMODEL_NAMEis valid for the selected provider. - If
pip installstarts failing with certificate verification again after switching Python versions, the new Python installation may need its CA bundle repaired separately. - If imports fail for code under
src/, prefer running commands throughmakeor withPYTHONPATH=src. - If sandbox tests fail unexpectedly, rerun
make example-testbefore changing agent code so you know whether the breakage came from the sandbox repo or your new code.
If you are not sure what to do next, spend the next hour like this:
- Run
make chat-basiconce and read chat_basic.py line by line. - Run
make example-runandmake example-testonce so you know the sandbox repo baseline. - Create
src/mini_coding_agent/structured_output.py. - Write a short note in
notes/week1.mdexplaining the boundary between "model output" and "application code".