KatalockAi AcademyBack to KatalockAi
Build track, required for the Phase 14 certificate

Build a coding-agent harness

Build every layer around a coding agent: loop contract, schema-checked tools, JSON-RPC, dispatcher, replanner, gates, sandbox, evals and traces, then prove it by fixing a bug in a repo you wrote.

about 26 h 10 guided steps Reviewed against a 6-point rubric
Submit your project Get coached by Professor Katalock

Build it step by step

  1. 1Agent Harness Loop ContractPhase 19: Capstone projects
  2. 2Tool Registry with Schema ValidationPhase 19: Capstone projects
  3. 3JSON-RPC 2.0 Over Newline-Delimited StdioPhase 19: Capstone projects
  4. 4Function Call DispatcherPhase 19: Capstone projects
  5. 5Plan-Execute Control FlowPhase 19: Capstone projects
  6. 6Capstone Lesson 25: Verification Gates and the Observation BudgetPhase 19: Capstone projects
  7. 7Capstone Lesson 26: Sandbox Runner with Denylist and Path JailPhase 19: Capstone projects
  8. 8Capstone Lesson 27: Eval Harness with Fixture TasksPhase 19: Capstone projects
  9. 9Capstone Lesson 28: Observability with OTel GenAI Spans and Prometheus MetricsPhase 19: Capstone projects
  10. 10Capstone Lesson 29: End-to-End Coding Agent on the HarnessPhase 19: Capstone projects

What You'll Build

A stdlib Python agent harness built layer by layer, exactly as the track does it: a deterministic loop state machine, a tool registry with JSON Schema validation, a JSON-RPC 2.0 stdio transport, a dispatcher with timeouts and retries, a plan-execute replanner, a verification gate chain with an observation budget, a sandbox runner, a fixture eval harness and OTel-style telemetry. The finished harness drives a coding policy that reads a small multi-file repo, runs its tests, finds the bug, writes the fix and stops. The fixture repo and its bug are yours, not the lesson's fizz.py.

Requirements

  1. Loop contract. A HarnessLoop with the six states (IDLE, PLANNING, EXECUTING, AWAITINGTOOL, REFLECTING, DONE), the ten hook topics, the eleven typed event types and a budget envelope (turns, tool calls, wall clock) that yields to the caller instead of killing the session. All state changes go through one `transition` function.
  2. Tool registry. Register tools with name, description, schema, handler, idempotent and timeout_ms. Validate the eight-keyword JSON Schema subset (type, properties, required, enum, minLength, maxLength, pattern, items) and return json-pointer error paths such as /user/email. Re-registration without override=True is rejected.
  3. Transport. JSON-RPC 2.0 over newline-delimited stdio with the five standard error codes, no response to notifications, batch support, and a broken JSON line that returns -32700 with id: null and does not stop the stream.
  4. Dispatcher. Per-call timeout, exponential backoff with jitter (max 3 attempts) only for timeout or transient errors on idempotent tools, idempotency-key dedupe (two concurrent calls with the same key run the handler once), a semaphore concurrency limit, and one DispatchError envelope with kind, attempts and jsonrpc_code.
  5. Plan-execute. Typed Step records, replan from the cursor with the last error in context, a plan.diff event (removed, added, revised) on each revision, and hard max_steps and max_replans budgets.
  6. Gates and sandbox. A short-circuiting chain of WhitelistGate, RegexGate, RecencyGate and BudgetGate backed by an ObservationLedger. A Sandbox that refuses denylisted executables, interpreter -c/-e calls and shell metacharacters, jails paths with os.path.realpath, truncates oversized output and kills on timeout, returning a structured SandboxResult.
  7. Evals and telemetry. An eval harness with file_equals, regex_match and shell_exit_zero verifiers that reports pass@1, pass@k, mean and p95 latency as JSON over at least 5 fixture tasks you wrote yourself. Spans with GenAI attributes (gen_ai.operation.name, gen_ai.tool.name, usage tokens) written one per line to traces.jsonl, plus Prometheus text with a tools_called_total counter and a tool_latency_ms histogram.
  8. End-to-end demo. python main.py runs the coding policy on your fixture repo through every layer and asserts the five lesson 29 invariants: solved in fewer than 12 steps, observation budget never exceeded, zero gate denials on legal tools, one span per step in traces.jsonl, and a tools_called_total{tool="read_file"} line plus a tool_latency_ms histogram in the exposition. It exits 0.
  9. Adversarial run. A second script sends at least three hostile tool calls (for example rm -rf, a ../ path escape, python3 -c ...) and shows each refused with its reason, recorded in the trace.
  10. Tests. A pytest suite covering state transitions, schema error paths, JSON-RPC error codes, retry and dedupe, replan exhaustion, gate short-circuit and every sandbox refusal axis. All pass.

Constraints

  • Python 3.10+ standard library only; pytest for tests. Runs on any laptop CPU in seconds. No GPU, no network.
  • No API key is needed: the graded policy is deterministic, as in lesson 29. If you want an LLM policy, plug it in at the same policy seam through any OpenAI-compatible endpoint (the KatalockAi API, or a local model via Ollama or llama.cpp), but the deterministic run is what gets graded.
  • The sandbox is a development guardrail, not an OS security boundary. Run the adversarial script only inside a throwaway temp directory.

Stretch Goals

  • Swap the deterministic policy for an LLM policy and report its pass@1 and pass@k on your fixture tasks.
  • Add a circuit breaker to the dispatcher (kind="circuit_open") and a per-tool observation budget gate.
  • Add $ref and additionalProperties: false to the schema validator.

How to Submit

Public GitHub repo with main.py, adversarial.py, a harness/ package (one module per layer: loop, registry, transport, dispatcher, planner, gates, sandbox, evals, telemetry), fixtures/ (your buggy repo and eval tasks), tests/ and results/ (eval report JSON, a sample of traces.jsonl, the Prometheus text). The README must give the exact run commands, a short diagram or table of how a tool call flows through the layers, one design decision per layer, what the sandbox does not protect against, and a 3 to 5 sentence reflection on a bug you hit when composing the layers. Paste the outputs listed under evidence.

How It's Reviewed

Professor Katalock reads your repository and the evidence you paste, and scores each criterion out of 100. You pass with a weighted total of 70 or more and no criterion below 40. A copied or padded submission is flagged and fails.

CriterionWeightHow it's checked
End-to-end demo30Pasted `python main.py` output shows the fixture solved in fewer than 12 steps, observation budget not exceeded, zero denials on legal tools, span count equal to step count, and the Prometheus lines present; exit code 0; the fixture repo and bug are the learner's own, not lesson 29's fizz.py.
Layer contracts and tests25Pytest output passes; reviewer finds tests for loop transitions and budgets, json-pointer error paths, all five JSON-RPC codes, retry only on transient or timeout, idempotency dedupe, replan exhaustion and plan.diff.
Safety layers15Adversarial output shows at least three refusals with reasons; code shows realpath-based path jail, interpreter -c/-e blocking, short-circuit gate order and an observation ledger that the budget gate reads.
Evals and observability10results/ contains an eval report with pass@1, pass@k and latency over at least 5 learner-written tasks, and trace lines carry gen_ai attributes that parse as JSON.
Code quality10One module per layer with typed dataclasses, no copy-pasted logic between layers, clear entry points, no hidden network or API dependency.
README and reflection10README has run commands, the tool-call flow, a design choice per layer, sandbox limitations and a specific integration-bug reflection.

Submit

Push your work to a public GitHub repository with a README that explains how to run it, then paste the evidence below. Up to 3 reviews a day, free.

  • Full terminal output of `python main.py`, including the step trace and the five invariant checks
  • Output of `python -m pytest -q`
  • Output of `python adversarial.py` showing each refused call and its reason
  • The eval report JSON from results/ and the first 3 lines of traces.jsonl
  • The Prometheus exposition text printed at the end of the demo
  • A 3 to 5 sentence reflection on one integration bug and how you fixed it

Reviews are done by AI against the rubric above. They check the evidence in your repository; they are not a substitute for a human code review, and a review can be wrong. If you think it is, improve the README so the evidence is unmistakable and resubmit.