Base agent

1. Talk to an LLM

View this stage's code on GitHub →

The smallest possible agent isn't an agent at all: one prompt in, one response out, no memory, no tools. Before adding any of that, there has to be something that talks to an LLM API at all. Everything else in this project is this call, wrapped in more structure.

Only the bold arrows leave your machine, over the internet (HTTPS). The model never reads your files or runs anything: it can only ask, and petite does the work locally.

Your task

  1. Send a single prompt to an OpenAI-compatible chat completions endpoint.
  2. Print the response content. No tools, no loop — one request in, one answer out.

The solution

Try the task above first. When you want to compare, this is exactly the whole program at this stage (just diff 1 1 shows the same).

Show the solutionHide the solution +47 −0 lines
main.py+47 −0
⋯ """Stage 1: Talk to an LLM The smallest possible version of an AI coding assistant: take a promptfrom the command line, send it to an LLM, print the response. No tools yet. No loop. Just a single request/response round trip, usingthe OpenAI SDK pointed at OpenRouter (any OpenAI-compatible API works thesame way).""" import argparseimport osimport sys from openai import OpenAI API_KEY = os.getenv("OPENROUTER_API_KEY")BASE_URL = os.getenv("OPENROUTER_BASE_URL", "https://openrouter.ai/api/v1")MODEL = os.getenv("MODEL", "anthropic/claude-haiku-4.5")  def main():    parser = argparse.ArgumentParser(description="petite-harness: a tiny AI coding assistant")    parser.add_argument("-p", "--prompt", required=True, help="the task to ask the model")    args = parser.parse_args()     if not API_KEY:        raise RuntimeError("OPENROUTER_API_KEY is not set")     client = OpenAI(api_key=API_KEY, base_url=BASE_URL)     print(f"[main] sending prompt to {MODEL}", file=sys.stderr)     response = client.chat.completions.create(        model=MODEL,        messages=[{"role": "user", "content": args.prompt}],    )     if not response.choices:        raise RuntimeError("no choices in response")     print(response.choices[0].message.content)  if __name__ == "__main__":    main()

Try it

Run this stage's own code (after just setup), from the repo root:

just stage 1
cd .stages/01
just run "Please compute 2 + 3. Respond with only a number."

Expect: 5

.stages/01 is a git worktree: your checkout stays on main, so just keeps working there. Or browse it on GitHub; just clean-stages removes the worktrees.

Where this fits

The whole agent; this stage builds the highlighted part. Click any part to jump to its stage.

References

2. Read tool →