codegraff
Python client for the codegraff agent.
It drives the graff binary over its --json stdio protocol, with constants
auto-generated from graff --schema.
Install
pip install codegraff
Note the package / module name mismatch: the PyPI package is
codegraff, but the importable module isharness_sdk:from harness_sdk import Harness
Prerequisite: the graff binary
The SDK spawns the graff binary as a subprocess, so it must be installed:
curl -fsSL https://github.com/justrach/codegraff/releases/latest/download/install.sh | sh
If graff isn't on your PATH, point at it explicitly with the binary
argument (Harness(binary="./zig-out/bin/graff")).
Quick start
from harness_sdk import Harness
with Harness(yolo=True, model="gpt-5.5") as h:
# one-shot: ask() returns just the final text
print(h.ask("what is 2+2?"))
# streamed: chat() iterates event dicts
for ev in h.chat("read foo.txt"):
print(ev["type"], ev)
# replace or extend the system prompt
with Harness(yolo=True, system_prompt="You are a code-review bot. Only report bugs.") as bot:
print(bot.ask("review main.py"))
Harness accepts yolo, model, cwd, system_prompt, binary, and more.
model may be a model name or a provider id (e.g. "codex", "moonshot").
Also exported: MODELS and PROVIDERS.
Events
chat() yields event dicts, each with a type:
text— assistant text deltatool_call— the agent invoked a tool (name,input)tool_result— a tool returnedask_user— the agent needs input; answer it with thecall_idturn— turn finished; carries the final text,context_tokens, andcost_usderror— something went wrong
Remote (no local binary)
Edge / serverless runtimes can't spawn a subprocess. Run graff serve somewhere
and drive it over HTTP (stdlib urllib only):
from harness_sdk import RemoteHarness
with RemoteHarness("http://127.0.0.1:8787", token="...", yolo=True) as h:
print(h.ask("what is 2+2?"))
Links
- Repository: https://github.com/justrach/codegraff
- This package (PyPI): https://pypi.org/project/codegraff/
- TypeScript sibling (npm): https://www.npmjs.com/package/@codegraff/sdk
License
BSD-3-Clause
Release files for codegraff 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| codegraff-0.3.1.tar.gz | 9.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| codegraff-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.1 kB
Release files / codegraff-0.3.1.tar.gz
| Download URL | codegraff-0.3.1.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
282f13ca232dae68f2a678c7170268cd2a0611c3791ff8e25ff3b7affbf7b3b2
|
|
BLAKE2b-256 checksum How to use checksums |
aab2d8b9be6b42f14132a05b59a2c71793817b36732d44788b22328648e4e730
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 20, 2026.
Transparency logRelease files / codegraff-0.3.1-py3-none-any.whl
| Download URL | codegraff-0.3.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20d48e2eac3999621b232c56ddc8904214aa39ee7a1841ec4a7ac432a774e605
|
|
BLAKE2b-256 checksum How to use checksums |
cb296b5bc8e5daa45ca2a3c827bcf1c9b9a342fc5b5e75d64082d3c92ef98f9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 20, 2026.
Transparency log