Skip to main content

Quark

Lightning-fast micro-agent. A stripped-down alternative to heavy AI agents, executing tasks with minimal prompt overhead.

Quark is a minimal CLI agent loop: send a message, let the model call tools (read/edit/write files, list directories, optionally run shell commands), and get an answer back — with conversation history persisted to disk between runs. It talks to any LLM provider through a small abstraction layer (Anthropic and OpenAI included) instead of depending on a heavy vendor SDK.

Two things it optimizes for on purpose:

  • Lightweight: no framework, no heavy SDKs (just httpx), a short default system prompt, and an edit_file tool so the model can make targeted changes instead of re-sending whole files.
  • Productive by default, secure by default: file tools are confined to a workspace directory (symlink escapes included), run_shell is off unless you opt in, and if a QUARK.md/AGENTS.md file exists it's folded into the system prompt automatically so the agent already knows about your project.

Install

Requires Python 3.10+. Works anywhere Python does, including WSL2 — nothing platform-specific.

./install.sh

Creates .venv, installs Quark editable with dev deps, and copies .env.example to .env if you don't already have one. Safe to re-run (reuses the venv, never overwrites an existing .env).

Or by hand:

python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Configure

Copy .env.example to .env (done automatically by install.sh) and fill in the key(s) for the provider(s) you want to use:

cp .env.example .env
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
QUARK_PROVIDER=anthropic

.env is loaded automatically from the current working directory. You can also export the variables directly, or pass --api-key on the command line.

Usage

# One-shot message, prints the reply and exits
quark chat "list the files in this directory"

# Interactive REPL (Ctrl+D or 'exit' to quit)
quark chat

# Choose a provider/model
quark --provider openai --model gpt-4o chat "what's in README.md?"

# Named sessions keep separate histories on disk
quark --session project-a chat "remember that we're using Postgres"
quark --session project-a chat "what database are we using?"

# Confine file tools to a specific directory (default: cwd)
quark --workspace ./my-project chat "list the files here"

# Opt in to the run_shell tool (off by default)
quark --allow-shell chat "run the test suite"

# Read-only mode: only read_file + list_dir, smallest tool-schema footprint, no escape hatch
quark --minimal-tools chat "what does this project do?"

# Progressive mode: starts like --minimal-tools, but the model can unlock
# write_file/edit_file/delete_file itself the moment it actually needs them
quark --progressive-tools chat "fix the typo in README.md"

# Print the full reply at once instead of streaming it token by token
quark --no-stream chat "what's in README.md?"

# Lower the threshold for auto-summarizing older turns (in estimated tokens)
quark --compact-threshold 4000 chat "..."

# Manage sessions
quark sessions list
quark sessions clear project-a

Sessions are stored as JSON under ~/.quark/sessions/<name>.json.

Project context

If a QUARK.md or AGENTS.md file exists at the workspace root, its contents are appended to the system prompt automatically — a cheap way to give the agent standing context (stack, conventions, gotchas) without repeating it every session.

Progressive tool disclosure

--progressive-tools (also QUARK_PROGRESSIVE_TOOLS=1) starts a turn with just read_file, list_dir, and one cheap extra tool, request_more_tools (no parameters). Its description tells the model to call it if it needs to write, edit, or delete files. If the model calls it, Quark registers write_file/edit_file/delete_file on the spot, drops request_more_tools (no longer needed), and the same agent.step() call retries with the expanded set — so the model still gets everything it needs, in the same turn, it just asks first.

This is deliberately not a heuristic: matching intent from text (keywords, embeddings, a classifier) always trades accuracy for cost and can silently withhold a tool the model actually needed on some phrasing you didn't anticipate. Letting the model itself request more tools can't misfire that way — the only cost is one extra round trip, and only on turns that actually mutate something. run_shell stays independently gated behind --allow-shell; progressive mode never unlocks it.

--minimal-tools is the stricter sibling: same starting set, but with no request_more_tools escape hatch at all, for when you want a hard read-only guarantee. Passing both flags together, --minimal-tools wins.

Streaming

Replies print as the model generates them — both providers use stream: true and parse server-sent events, calling back into the CLI for each text chunk. Tool calls are accumulated silently (their JSON arguments arrive fragmented) and only run once complete; nothing changes about tool behavior, just how text reaches your terminal. Pass --no-stream to wait for the full reply and print it in one shot instead (e.g. for piping output into another program).

Context compaction

Quark estimates the session's token count (a len(text) // 4 heuristic — no tokenizer dependency) before each turn. Once it's over --compact-threshold (default 20000, also QUARK_COMPACT_THRESHOLD), it asks the model for a short summary of the older turns and folds that summary into the oldest turn it keeps, dropping everything before it. It only ever cuts at a turn boundary — right after a completed assistant reply, never mid-tool-call — so this can't break the strict user/assistant alternation Anthropic's API requires. Pass --compact-threshold 0 to disable it.

Token overhead

On the first turn (empty session), before the model generates anything, Quark sends the system prompt plus the JSON schema of every registered tool. Rough token counts (tiktoken cl100k_base, an approximation — Claude's real tokenizer isn't public — but the right order of magnitude either way):

Mode Tools registered Tool-schema tokens Total (system + tools + a short message)
default read_file, list_dir, write_file, edit_file, delete_file ~380 ~415
--minimal-tools read_file, list_dir ~120 ~155
--progressive-tools, before unlocking read_file, list_dir, request_more_tools ~165 ~200
--progressive-tools, after unlocking same as default ~380 ~415
default + --allow-shell + run_shell ~380 + ~65 ~480

--minimal-tools is cheapest but can never write/edit/delete. --progressive-tools costs a little more than minimal on read-only turns (~200 vs ~155) but is capability-equivalent to the default the moment it's actually needed — it only pays the full ~415 on turns that mutate something. Every subsequent turn in a session also carries the accumulated conversation history on top of these numbers.

Architecture

quark/
  message.py       Internal Message/ToolCall representation
  session.py        Persistent, named conversation history
  agent.py           The chat + tool-calling loop
  compact.py          Token-threshold-based history summarization
  providers/          Provider abstraction (unified request/response shape)
    base.py
    anthropic.py       Anthropic Messages API, streamed (SSE)
    openai.py           OpenAI Chat Completions API, streamed (SSE)
  tools/               Built-in tools the agent can call
    base.py             Tool + ToolRegistry
    workspace.py         Path confinement (resolve_within)
    fs.py                read_file / write_file / edit_file / delete_file / list_dir
    shell.py             run_shell (opt-in)
    meta.py              request_more_tools (--progressive-tools)
  cli.py               argparse-based entry point

Adding a provider means implementing Provider.complete() in quark/providers/ and registering it in quark/providers/__init__.py. Adding a tool means subclassing Tool in quark/tools/ and adding it to default_registry().

Security note

  • read_file, write_file, edit_file, delete_file, and list_dir are confined to --workspace (default: the current directory); paths that escape it, including via symlinks, are rejected.
  • run_shell executes arbitrary shell commands and is off by default — enable it with --allow-shell or QUARK_ALLOW_SHELL=1 only when you trust the prompts/provider you're running against.
  • write_file and delete_file still mutate the filesystem inside the workspace without asking for confirmation. Only point Quark at trusted providers/prompts, and run it in an environment you're comfortable with an autonomous agent touching.

Development

pip install -e ".[dev]"
pytest

Tests mock the HTTP layer (httpx.stream), so the suite runs offline with no API keys required.

Publishing to PyPI

The project builds as quark-ai (the CLI command stays quark either way — the package name on PyPI doesn't have to match the command it installs). .github/workflows/publish.yml publishes to PyPI via Trusted Publishing (OIDC) whenever a GitHub Release is published — no API token stored in the repo.

One-time setup (done from your own PyPI account, not from CI):

  1. Create a PyPI account at pypi.org if you don't have one, and enable 2FA (PyPI requires it).
  2. Go to pypi.org/manage/account/publishing and add a pending publisher: PyPI project name quark-ai, owner rmoya81, repository Quark, workflow publish.yml, environment pypi. This reserves the name immediately — the project is created the moment the first publish succeeds, and only this repo's workflow can publish to it.
  3. In the GitHub repo, create an environment named pypi (Settings → Environments), matching the one in the workflow and in the pending publisher config.
  4. Cut a GitHub Release (tag v0.1.0 or similar) — the workflow builds the sdist/wheel and publishes them automatically.

To claim the name immediately instead of waiting on that setup (e.g. to block squatting right now), a one-off manual publish works too: pip install build twine && python -m build && twine upload dist/* with a PyPI API token — quark-ai/quark-cli/quarkagent/quark-micro-agent/quark-llm-agent are all currently unregistered as of this writing; quark and quark-agent are already taken by unrelated projects.

Metadata

Release files for quark-ai 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quark-ai 0.2.0
File Size Uploaded Provenance Actions
quark_ai-0.2.0.tar.gz 25.2 kB With provenance Details for quark_ai-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for quark-ai 0.2.0
File Interpreter ABI Platform Actions
quark_ai-0.2.0-py3-none-any.whl Python 3 none any Details for quark_ai-0.2.0-py3-none-any.whl

Total release size: 48.3 kB

Release files / quark_ai-0.2.0.tar.gz

Download URL quark_ai-0.2.0.tar.gz
Size 25.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bf64cd542438b4eab1c404052b3614d2bcfaeacfdb29925612e2d5384bb9bf9d
BLAKE2b-256 checksum
How to use checksums
01a913909cc4f0df0f6ddaba590fb86f638b14143fecce37aba70a530ad7c0e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 1, 2026.

Transparency log

Release files / quark_ai-0.2.0-py3-none-any.whl

Download URL quark_ai-0.2.0-py3-none-any.whl
Size 23.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69f4b580efc95da42c666affa80fe18dbbbcff5941bcdadc2a2c0dca4d0b8418
BLAKE2b-256 checksum
How to use checksums
c1877da44ea3ae23ec01c457395ae26c89b42aed58fc0d68f99fbd4c3da100c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 1, 2026.

Transparency log

Security for quark-ai 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for quark_ai-0.2.0.tar.gz

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 Oct 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page