localmend 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- localmend-0.1.0/.github/workflows/publish.yml +45 -0
- localmend-0.1.0/.github/workflows/test.yml +13 -0
- localmend-0.1.0/.gitignore +26 -0
- localmend-0.1.0/LICENSE +21 -0
- localmend-0.1.0/PKG-INFO +451 -0
- localmend-0.1.0/README.md +426 -0
- localmend-0.1.0/SECURITY.md +38 -0
- localmend-0.1.0/bench/compare.py +31 -0
- localmend-0.1.0/bench/run.py +322 -0
- localmend-0.1.0/bench/tasks/h01_hidden_bug/check_test.py +8 -0
- localmend-0.1.0/bench/tasks/h01_hidden_bug/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/h01_hidden_bug/repo/shop/__init__.py +0 -0
- localmend-0.1.0/bench/tasks/h01_hidden_bug/repo/shop/cart.py +18 -0
- localmend-0.1.0/bench/tasks/h01_hidden_bug/repo/shop/discount.py +8 -0
- localmend-0.1.0/bench/tasks/h01_hidden_bug/repo/shop/prices.py +4 -0
- localmend-0.1.0/bench/tasks/h01_hidden_bug/repo/tests/test_cart.py +7 -0
- localmend-0.1.0/bench/tasks/h02_multifile_feature/check_test.py +10 -0
- localmend-0.1.0/bench/tasks/h02_multifile_feature/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/h02_multifile_feature/repo/todo/__init__.py +0 -0
- localmend-0.1.0/bench/tasks/h02_multifile_feature/repo/todo/cli.py +8 -0
- localmend-0.1.0/bench/tasks/h02_multifile_feature/repo/todo/model.py +6 -0
- localmend-0.1.0/bench/tasks/h02_multifile_feature/repo/todo/store.py +8 -0
- localmend-0.1.0/bench/tasks/h03_run_to_find/check_test.py +4 -0
- localmend-0.1.0/bench/tasks/h03_run_to_find/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/h03_run_to_find/repo/report.py +15 -0
- localmend-0.1.0/bench/tasks/h03_run_to_find/repo/sales.csv +6 -0
- localmend-0.1.0/bench/tasks/h04_long_file/check_test.py +4 -0
- localmend-0.1.0/bench/tasks/h04_long_file/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/h04_long_file/repo/utils.py +326 -0
- localmend-0.1.0/bench/tasks/h05_refactor/check_test.py +12 -0
- localmend-0.1.0/bench/tasks/h05_refactor/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/h05_refactor/repo/test_users.py +12 -0
- localmend-0.1.0/bench/tasks/h05_refactor/repo/users.py +15 -0
- localmend-0.1.0/bench/tasks/t01_offbyone/check_test.py +5 -0
- localmend-0.1.0/bench/tasks/t01_offbyone/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/t01_offbyone/repo/pager.py +4 -0
- localmend-0.1.0/bench/tasks/t02_slugify/check_test.py +5 -0
- localmend-0.1.0/bench/tasks/t02_slugify/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/t02_slugify/repo/text.py +3 -0
- localmend-0.1.0/bench/tasks/t03_rename/check_test.py +8 -0
- localmend-0.1.0/bench/tasks/t03_rename/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/t03_rename/repo/api.py +4 -0
- localmend-0.1.0/bench/tasks/t03_rename/repo/billing.py +2 -0
- localmend-0.1.0/bench/tasks/t03_rename/repo/report.py +4 -0
- localmend-0.1.0/bench/tasks/t04_validate/check_test.py +8 -0
- localmend-0.1.0/bench/tasks/t04_validate/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/t04_validate/repo/account.py +7 -0
- localmend-0.1.0/bench/tasks/t05_kvparse/check_test.py +5 -0
- localmend-0.1.0/bench/tasks/t05_kvparse/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/t05_kvparse/repo/config.py +4 -0
- localmend-0.1.0/bench/tasks/t06_money/check_test.py +3 -0
- localmend-0.1.0/bench/tasks/t06_money/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/t06_money/repo/money.py +3 -0
- localmend-0.1.0/bench/tasks/t07_cache/check_test.py +4 -0
- localmend-0.1.0/bench/tasks/t07_cache/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/t07_cache/repo/fib.py +8 -0
- localmend-0.1.0/bench/tasks/t08_bugfind/check_test.py +3 -0
- localmend-0.1.0/bench/tasks/t08_bugfind/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/t08_bugfind/repo/stats.py +10 -0
- localmend-0.1.0/bench/tasks/t08_bugfind/repo/test_stats.py +5 -0
- localmend-0.1.0/bench/tasks/t09_cli/check_test.py +5 -0
- localmend-0.1.0/bench/tasks/t09_cli/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/t09_cli/repo/tool.py +9 -0
- localmend-0.1.0/bench/tasks/t10_newfile/check_test.py +4 -0
- localmend-0.1.0/bench/tasks/t10_newfile/prompt.txt +1 -0
- localmend-0.1.0/bench/tasks/t10_newfile/repo/README.md +2 -0
- localmend-0.1.0/docs/RESULTS.md +307 -0
- localmend-0.1.0/docs/demo.svg +39 -0
- localmend-0.1.0/docs/make_demo.py +86 -0
- localmend-0.1.0/pyproject.toml +45 -0
- localmend-0.1.0/src/localmend/__init__.py +1 -0
- localmend-0.1.0/src/localmend/banner.py +66 -0
- localmend-0.1.0/src/localmend/check.py +220 -0
- localmend-0.1.0/src/localmend/checks.py +69 -0
- localmend-0.1.0/src/localmend/cli.py +250 -0
- localmend-0.1.0/src/localmend/doctor.py +398 -0
- localmend-0.1.0/src/localmend/fixes/__init__.py +0 -0
- localmend-0.1.0/src/localmend/fixes/anthropic.py +136 -0
- localmend-0.1.0/src/localmend/fixes/prefix.py +287 -0
- localmend-0.1.0/src/localmend/fixes/sidecalls.py +95 -0
- localmend-0.1.0/src/localmend/fixes/sysmerge.py +87 -0
- localmend-0.1.0/src/localmend/fixes/verify.py +283 -0
- localmend-0.1.0/src/localmend/responses.py +186 -0
- localmend-0.1.0/src/localmend/server.py +587 -0
- localmend-0.1.0/src/localmend/sse.py +62 -0
- localmend-0.1.0/src/localmend/trace.py +27 -0
- localmend-0.1.0/src/localmend/upstream.py +72 -0
- localmend-0.1.0/tests/test_anthropic.py +442 -0
- localmend-0.1.0/tests/test_banner.py +63 -0
- localmend-0.1.0/tests/test_check.py +119 -0
- localmend-0.1.0/tests/test_doctor.py +282 -0
- localmend-0.1.0/tests/test_prefix.py +190 -0
- localmend-0.1.0/tests/test_responses.py +154 -0
- localmend-0.1.0/tests/test_server.py +600 -0
- localmend-0.1.0/tests/test_sidecalls.py +76 -0
- localmend-0.1.0/tests/test_sysmerge.py +121 -0
- localmend-0.1.0/tests/test_upstream.py +46 -0
- localmend-0.1.0/tests/test_verify.py +99 -0
- localmend-0.1.0/uv.lock +317 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
# Runs when a GitHub release is published: tests, build, upload to PyPI.
|
|
3
|
+
# Uses PyPI trusted publishing, so no token is stored anywhere.
|
|
4
|
+
on:
|
|
5
|
+
release:
|
|
6
|
+
types: [published]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: astral-sh/setup-uv@v5
|
|
14
|
+
- run: uv run --python 3.12 pytest -q
|
|
15
|
+
|
|
16
|
+
build:
|
|
17
|
+
needs: test
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- uses: astral-sh/setup-uv@v5
|
|
22
|
+
- run: uv build
|
|
23
|
+
- name: the release tag must match the package version
|
|
24
|
+
run: |
|
|
25
|
+
v=$(grep -m1 '^version' pyproject.toml | cut -d'"' -f2)
|
|
26
|
+
test "v$v" = "${{ github.event.release.tag_name }}" || { echo "tag ${{ github.event.release.tag_name }} != version $v"; exit 1; }
|
|
27
|
+
- uses: actions/upload-artifact@v4
|
|
28
|
+
with:
|
|
29
|
+
name: dist
|
|
30
|
+
path: dist/
|
|
31
|
+
|
|
32
|
+
pypi:
|
|
33
|
+
needs: build
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
environment:
|
|
36
|
+
name: pypi
|
|
37
|
+
url: https://pypi.org/p/localmend
|
|
38
|
+
permissions:
|
|
39
|
+
id-token: write # trusted publishing
|
|
40
|
+
steps:
|
|
41
|
+
- uses: actions/download-artifact@v4
|
|
42
|
+
with:
|
|
43
|
+
name: dist
|
|
44
|
+
path: dist/
|
|
45
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
jobs:
|
|
4
|
+
test:
|
|
5
|
+
strategy:
|
|
6
|
+
matrix:
|
|
7
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
8
|
+
python: ["3.10", "3.13"]
|
|
9
|
+
runs-on: ${{ matrix.os }}
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: astral-sh/setup-uv@v5
|
|
13
|
+
- run: uv run --python ${{ matrix.python }} pytest -q
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.venv/
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.pyc
|
|
4
|
+
*.jsonl
|
|
5
|
+
.pytest_cache/
|
|
6
|
+
dist/
|
|
7
|
+
bench/results/
|
|
8
|
+
|
|
9
|
+
# Secrets and local settings: never commit these
|
|
10
|
+
.env
|
|
11
|
+
.env.*
|
|
12
|
+
!.env.example
|
|
13
|
+
*.pem
|
|
14
|
+
*.key
|
|
15
|
+
*.p12
|
|
16
|
+
*.pfx
|
|
17
|
+
id_rsa*
|
|
18
|
+
id_ed25519*
|
|
19
|
+
*secret*
|
|
20
|
+
*credential*
|
|
21
|
+
.fcc/
|
|
22
|
+
.codex/
|
|
23
|
+
.claude/settings.local.json
|
|
24
|
+
# Traces and logs hold full prompts and code
|
|
25
|
+
*.log
|
|
26
|
+
traces/
|
localmend-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 localmend contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
localmend-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: localmend
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Find out why your coding agent is slow or wrong on a local model, and fix it: a diagnosing proxy for llama.cpp, Ollama and LM Studio.
|
|
5
|
+
Project-URL: Homepage, https://github.com/rodricksz4h5/localmend
|
|
6
|
+
Project-URL: Results, https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md
|
|
7
|
+
Project-URL: Issues, https://github.com/rodricksz4h5/localmend/issues
|
|
8
|
+
Project-URL: Security, https://github.com/rodricksz4h5/localmend/blob/main/SECURITY.md
|
|
9
|
+
Author: rodricksz4h5
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: claude-code,coding-agent,llama.cpp,llm,lm-studio,local-llm,ollama,prompt-cache,proxy
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Classifier: Topic :: Software Development
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: httpx<1,>=0.27
|
|
22
|
+
Requires-Dist: starlette<2,>=0.40
|
|
23
|
+
Requires-Dist: uvicorn>=0.30
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# localmend
|
|
27
|
+
|
|
28
|
+
[](https://github.com/rodricksz4h5/localmend/actions/workflows/test.yml)
|
|
29
|
+

|
|
30
|
+
[](https://github.com/rodricksz4h5/localmend/blob/main/LICENSE)
|
|
31
|
+
|
|
32
|
+
**Find out why your coding agent is slow or wrong on a local model, and fix it.**
|
|
33
|
+
|
|
34
|
+
[Quick start](#quick-start) · [Connect your app](#connect-your-app) · [Diagnose](#diagnose-your-own-setup) ·
|
|
35
|
+
[Results](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md) · [Troubleshooting](#troubleshooting) · [FAQ](#faq)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
uv tool install git+https://github.com/rodricksz4h5/localmend
|
|
39
|
+
localmend check # is your model server set up for coding agents? (about a minute)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Coding agents (Claude Code, OpenCode, Aider, Hermes, Qwen Code, Codex CLI, …) are built for big cloud
|
|
43
|
+
models. Point them at a 4B–9B model on your own machine and they often waste minutes per task,
|
|
44
|
+
or say "done" without checking. localmend sits between your agent and your model server
|
|
45
|
+
(llama.cpp, Ollama or LM Studio), shows you what is going wrong, and fixes what a proxy can fix,
|
|
46
|
+
without changing the agent or the model.
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
your agent ──► localmend :4747 ──► llama.cpp / Ollama / LM Studio
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
- `localmend check`: is your model server set up for agents?
|
|
53
|
+
- `localmend serve`: the proxy, with fixes for the problems below
|
|
54
|
+
- `localmend doctor`: what does *your* agent waste time on? (reads a recorded session)
|
|
55
|
+
- `localmend report`: every request of a recorded session, one line each
|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
<sub>**Claude Code + Qwen3.5-4B on a laptop without a GPU: every request fails → works; 15 tasks in
|
|
60
|
+
52 min instead of 84.** One laptop, one or two runs per setup; your numbers will differ.
|
|
61
|
+
[All results](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md).</sub>
|
|
62
|
+
|
|
63
|
+
## Why
|
|
64
|
+
|
|
65
|
+
Coding agents are built for big cloud models. On a 4B–9B model on a laptop, three things go wrong
|
|
66
|
+
that a proxy can fix:
|
|
67
|
+
|
|
68
|
+
1. **The prompt cache never hits.** Agents put the date, working directory or a file list in their
|
|
69
|
+
system prompt, so the server re-reads ~10–20k tokens: **~3 minutes** before the first word of
|
|
70
|
+
each new session.
|
|
71
|
+
2. **The model says "done" without checking.** Small models edit a file and stop without running
|
|
72
|
+
anything, and the agent believes it.
|
|
73
|
+
3. **Housekeeping calls eat the GPU.** A thinking model reasons for thousands of tokens about a
|
|
74
|
+
five-word thread title while the real work waits: **100–800 s per title** in our runs.
|
|
75
|
+
|
|
76
|
+
## Per app
|
|
77
|
+
|
|
78
|
+
Measured on one laptop without a GPU (i7-1260P, Intel Iris Xe, 16 GB), Qwen3.5-4B unless noted.
|
|
79
|
+
Each row links to the full numbers and caveats.
|
|
80
|
+
|
|
81
|
+
| App | What `doctor` found | What localmend changes |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| [**OpenCode**](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#opencode) 2.3 / 1.19 | Changing prompt, slow title requests, finishes without testing | 3 wrong answers → 0 (2.3); 1.6x faster (1.19); [2.2x on Ollama](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#opencode-on-ollama) |
|
|
84
|
+
| [**Claude Code**](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#claude-code) | Fails outright on Qwen3.5 + llama.cpp (late system message); billing line breaks the cache | Works at all; 84 → 52 min for 15 tasks |
|
|
85
|
+
| [**Hermes Agent**](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#hermes-agent) | Workspace info in the prompt: full re-read per task | 31% faster, same results (15/15) |
|
|
86
|
+
| [**Aider**](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#aider) | Commit message request thinks for 10+ min, then retried | Commit messages in 7–12 s; 3/3 tasks done |
|
|
87
|
+
| [**Qwen Code**](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#qwen-code) | Memory folder path in the prompt: full re-read per task | Re-reads 16 → 4, but total time about even |
|
|
88
|
+
| [**Cline CLI**](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#cline-cli) | Healthy: small prompt, tests its own work | Nothing needed |
|
|
89
|
+
| [**Codex CLI**](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#codex-cli) | Fails outright on Qwen3.5 + llama.cpp (developer message after its instructions) | Works at all; the 4B model still can't edit files with it |
|
|
90
|
+
| [**Free Claude Code**](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#free-claude-code) (Claude Code via FCC) | Every new task re-reads the whole prompt; FCC gives up after 120 s and resends | 16.4 → 10.1 min for 3 tasks, no more timeouts |
|
|
91
|
+
| [**Odysseus**](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#odysseus) (chat) | `think: false` ignored by Ollama | 2.7x less waiting |
|
|
92
|
+
| [Gemma 4 E4B](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#gemma-4-e4b-on-ollama) (Ollama) | Same problems, model-specific cache limits | 14/15 vs 13/15 with OpenCode; [no help with Claude Code](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#gemma-4-e4b-with-claude-code-on-ollama) |
|
|
93
|
+
|
|
94
|
+
One run per setup unless noted, so treat small differences as noise. Reproduce with
|
|
95
|
+
[bench/](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#reproduce-the-benchmark).
|
|
96
|
+
|
|
97
|
+
### Not for you if…
|
|
98
|
+
|
|
99
|
+
- **You use a cloud model.** localmend is for local servers; cloud APIs cache prompts differently.
|
|
100
|
+
- **Your agent is already healthy.** Cline CLI needed nothing in our runs. Run `doctor` on your own
|
|
101
|
+
sessions first: it says when there's nothing to fix.
|
|
102
|
+
- **Claude Code with Gemma 4 on Ollama.** Connecting Claude Code to Ollama directly worked as well
|
|
103
|
+
or better in our runs.
|
|
104
|
+
- **You expect a 4B model to drive Codex CLI.** localmend makes Codex work at all, but its file
|
|
105
|
+
editing tool isn't offered to models it doesn't know, and that a proxy can't fix.
|
|
106
|
+
|
|
107
|
+
## Quick start
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# 1. a local model server, e.g. llama.cpp
|
|
111
|
+
llama-server -m Qwen3.5-4B-Q4_K_M.gguf --jinja -ngl 99 -c 32768 --port 8080 # agents need 20k+
|
|
112
|
+
|
|
113
|
+
# or Ollama: OLLAMA_CONTEXT_LENGTH=32768 OLLAMA_IGPU_ENABLE=1 ollama serve (upstream :11434)
|
|
114
|
+
|
|
115
|
+
# 2. the proxy (uv brings its own Python if yours is older than 3.10)
|
|
116
|
+
uv tool install git+https://github.com/rodricksz4h5/localmend # or: pipx install git+...
|
|
117
|
+
localmend check --upstream http://127.0.0.1:8080 # a minute: is the server set up for agents?
|
|
118
|
+
localmend serve --upstream http://127.0.0.1:8080
|
|
119
|
+
|
|
120
|
+
# 3. point your agent at http://127.0.0.1:4747/v1, see "Connect your app" below
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Each request prints one line: time, prompt tokens read vs reused, thinking length, and which fixes
|
|
124
|
+
fired (`--quiet` turns this off).
|
|
125
|
+
|
|
126
|
+
<details>
|
|
127
|
+
<summary><b>On a Mac</b></summary>
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
brew install llama.cpp # Metal (Apple GPU) support is built in
|
|
131
|
+
llama-server -m Qwen3.5-4B-Q4_K_M.gguf --jinja -c 32768 --port 8080
|
|
132
|
+
|
|
133
|
+
# or the Ollama app: raise its context length in Settings, or
|
|
134
|
+
launchctl setenv OLLAMA_CONTEXT_LENGTH 32768 # then quit and reopen Ollama
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
No `OLLAMA_IGPU_ENABLE` there: on Apple Silicon Ollama uses the GPU by itself. `mlx_lm.server`
|
|
138
|
+
also speaks the OpenAI API, so localmend can sit in front of it too.
|
|
139
|
+
</details>
|
|
140
|
+
|
|
141
|
+
<details>
|
|
142
|
+
<summary><b>LM Studio</b></summary>
|
|
143
|
+
|
|
144
|
+
Use `--upstream http://127.0.0.1:1234`. Tested on LM Studio 0.4.29 (Windows) with `check` and single
|
|
145
|
+
requests, no full agent run yet: it accepts a late system message, ignores the usual no-thinking
|
|
146
|
+
switch but honours `reasoning_effort: "none"`, which localmend sends to it, and `check` reads its
|
|
147
|
+
loaded context size (raise it with `lms load <model> -c 32768`).
|
|
148
|
+
</details>
|
|
149
|
+
|
|
150
|
+
## Connect your app
|
|
151
|
+
|
|
152
|
+
Start the proxy in front of your model server, then point the app at `http://127.0.0.1:4747/v1`
|
|
153
|
+
(any API key works, e.g. `local`; with llama.cpp any model name works, with Ollama use its name,
|
|
154
|
+
e.g. `qwen3.5:4b`):
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
localmend serve --upstream http://127.0.0.1:8080 # llama.cpp; Ollama: http://127.0.0.1:11434
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
<details>
|
|
161
|
+
<summary><b>OpenCode</b></summary>
|
|
162
|
+
|
|
163
|
+
A provider in `opencode.json`:
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"provider": {"local": {
|
|
168
|
+
"npm": "@ai-sdk/openai-compatible",
|
|
169
|
+
"options": {"baseURL": "http://127.0.0.1:4747/v1"},
|
|
170
|
+
"models": {"qwen": {"tool_call": true, "limit": {"context": 32768, "output": 4096}}}
|
|
171
|
+
}},
|
|
172
|
+
"model": "local/qwen"
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
</details>
|
|
176
|
+
|
|
177
|
+
<a id="claude-code-settings"></a>
|
|
178
|
+
<details>
|
|
179
|
+
<summary><b>Claude Code</b></summary>
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
export ANTHROPIC_BASE_URL=http://127.0.0.1:4747 # just the address, no /v1
|
|
183
|
+
export ANTHROPIC_AUTH_TOKEN=local
|
|
184
|
+
export ANTHROPIC_MODEL=qwen ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen # llama-server takes any name; Ollama: e.g. qwen3.5:4b
|
|
185
|
+
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=32768 # your server's context; else Claude Code assumes 1M and overflows it
|
|
186
|
+
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=4096 # needed with the line above: Claude Code keeps room for a 32k
|
|
187
|
+
# reply, so a 32k window looks full and it compacts every turn
|
|
188
|
+
export API_TIMEOUT_MS=3600000 # a session's first request can take minutes on a laptop
|
|
189
|
+
claude
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
PowerShell:
|
|
193
|
+
|
|
194
|
+
```powershell
|
|
195
|
+
$env:ANTHROPIC_BASE_URL="http://127.0.0.1:4747"; $env:ANTHROPIC_AUTH_TOKEN="local"; $env:ANTHROPIC_MODEL="qwen"
|
|
196
|
+
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen"; $env:CLAUDE_CODE_MAX_CONTEXT_TOKENS="32768"; $env:CLAUDE_CODE_MAX_OUTPUT_TOKENS="4096"
|
|
197
|
+
$env:API_TIMEOUT_MS="3600000"
|
|
198
|
+
claude
|
|
199
|
+
```
|
|
200
|
+
</details>
|
|
201
|
+
|
|
202
|
+
<details>
|
|
203
|
+
<summary><b>Hermes Agent</b></summary>
|
|
204
|
+
|
|
205
|
+
In `config.yaml` (64k context or more, Hermes' own minimum):
|
|
206
|
+
|
|
207
|
+
```yaml
|
|
208
|
+
model:
|
|
209
|
+
provider: custom
|
|
210
|
+
base_url: http://127.0.0.1:4747/v1
|
|
211
|
+
default: qwen
|
|
212
|
+
context_length: 65536
|
|
213
|
+
```
|
|
214
|
+
</details>
|
|
215
|
+
|
|
216
|
+
<details>
|
|
217
|
+
<summary><b>Aider</b></summary>
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
OPENAI_API_BASE=http://127.0.0.1:4747/v1 OPENAI_API_KEY=local aider --model openai/qwen
|
|
221
|
+
```
|
|
222
|
+
</details>
|
|
223
|
+
|
|
224
|
+
<details>
|
|
225
|
+
<summary><b>Qwen Code</b></summary>
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
qwen --auth-type openai --openai-base-url http://127.0.0.1:4747/v1 --openai-api-key local -m qwen
|
|
229
|
+
```
|
|
230
|
+
</details>
|
|
231
|
+
|
|
232
|
+
<details>
|
|
233
|
+
<summary><b>Cline CLI</b></summary>
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
cline auth -p openai -k local -m qwen -b http://127.0.0.1:4747/v1
|
|
237
|
+
```
|
|
238
|
+
</details>
|
|
239
|
+
|
|
240
|
+
<details>
|
|
241
|
+
<summary><b>Codex CLI</b></summary>
|
|
242
|
+
|
|
243
|
+
In `~/.codex/config.toml`:
|
|
244
|
+
|
|
245
|
+
```toml
|
|
246
|
+
model = "qwen"
|
|
247
|
+
model_provider = "local"
|
|
248
|
+
model_context_window = 32768
|
|
249
|
+
|
|
250
|
+
[model_providers.local]
|
|
251
|
+
name = "local"
|
|
252
|
+
base_url = "http://127.0.0.1:4747/v1"
|
|
253
|
+
wire_api = "responses"
|
|
254
|
+
```
|
|
255
|
+
</details>
|
|
256
|
+
|
|
257
|
+
<details>
|
|
258
|
+
<summary><b>Free Claude Code (FCC)</b></summary>
|
|
259
|
+
|
|
260
|
+
In `~/.fcc/.env`, point its local provider at localmend instead of the model server, and start
|
|
261
|
+
localmend with `--upstream` set to the model server:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
MODEL="llamacpp/qwen"
|
|
265
|
+
LLAMACPP_BASE_URL="http://127.0.0.1:4747/v1"
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
(Measured with llama.cpp. FCC's LM Studio and Ollama providers speak the same API, so
|
|
269
|
+
`LM_STUDIO_BASE_URL` / `OLLAMA_BASE_URL` pointed at localmend should work the same way; not measured yet.)
|
|
270
|
+
</details>
|
|
271
|
+
|
|
272
|
+
**Anything else** with an "OpenAI-compatible" provider setting (Continue, Kilo, Goose, Open WebUI, …):
|
|
273
|
+
base URL `http://127.0.0.1:4747/v1`. These are not measured yet; run `doctor` on a session to see
|
|
274
|
+
whether localmend helps.
|
|
275
|
+
|
|
276
|
+
## What it does
|
|
277
|
+
|
|
278
|
+
| | What | Measured effect |
|
|
279
|
+
|---|---|---|
|
|
280
|
+
| **check** | Tests your model server the way an agent will use it, in about a minute: context size, prompt reading speed, cache reuse, chat template, thinking switch, GPU. Each problem comes with what to do. | — |
|
|
281
|
+
| **doctor** | Reads a recorded session and tells you which of these problems your agent has, where in the prompt the cache breaks, and how much time each one cost. | — |
|
|
282
|
+
| **prefix** fix | Moves the changing parts of the system prompt (date, cwd, env block) into the first user message, so the prefix is byte-identical across sessions. Known patterns plus automatic learning of the volatile region. | new session's first request: 167 s → 6.6 s |
|
|
283
|
+
| **verify** fix | If the model edited files, ran nothing since, and is about to give its final answer, the answer is held and the model is asked once to run one quick check. A few turns later it is asked to wrap up. The agent never sees any of this, and the server's prompt cache stays valid throughout. | failures 3 → 0 on OpenCode 2.3 |
|
|
284
|
+
| **sidecalls** fix | Recognised side requests (title generation, memory extraction) get thinking off; titles also get a short output cap. Agent turns are never touched. | title: 100–800 s → ~10 s |
|
|
285
|
+
| **think-flag** fix | If the app asks for no thinking with `think: false`, which Ollama's OpenAI-style endpoint silently ignores, the server's own switch is sent instead. Only acts on an explicit `false`. | Odysseus chat: 2.7x less waiting |
|
|
286
|
+
| **sysmerge** fix | Many chat templates (Qwen3.x and others) accept one system message, first, and fail the request otherwise ("System message must be at the beginning"). Claude Code and some other apps send more later on. When the server rejects a request for this, the later system messages are moved into the conversation at the same spot and the request is retried; from then on this is done up front for that model. | Claude Code + Qwen3.5: every request fails → works |
|
|
287
|
+
|
|
288
|
+
Every fix is on by default and can be switched off (`--no-prefix`, `--no-verify`, `--no-sidecalls`, `--no-think-flag`,
|
|
289
|
+
`--no-sysmerge`). `--observe` turns them all off except sysmerge, which only acts on requests the server
|
|
290
|
+
would otherwise refuse. Verify costs time (about 1.5x on OpenCode 2.3) for fewer wrong answers; use
|
|
291
|
+
`--no-verify` if you prefer speed.
|
|
292
|
+
|
|
293
|
+
## Diagnose your own setup
|
|
294
|
+
|
|
295
|
+
First the server on its own, about a minute, no agent needed:
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
localmend check --upstream http://127.0.0.1:11434 # Ollama; llama.cpp is the default :8080
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
<details>
|
|
302
|
+
<summary>Example output (Ollama left at its defaults)</summary>
|
|
303
|
+
|
|
304
|
+
```
|
|
305
|
+
ok server: ollama at http://127.0.0.1:11434, model qwen3.5:4b
|
|
306
|
+
PROBLEM context: 4,096 tokens. Coding agents send 10-22k tokens per request before any work, ...
|
|
307
|
+
do: set OLLAMA_CONTEXT_LENGTH=32768 and restart Ollama (or raise it in the app's Settings)
|
|
308
|
+
ok speed: reads 39 prompt tokens/s, so an agent's ~14k-token prompt takes ~355 s to read whenever the cache misses.
|
|
309
|
+
ok cache: a second prompt with the same start skipped the shared part (reused 1,325 of 1,837 tokens, ...
|
|
310
|
+
PROBLEM gpu: Ollama runs this model on the CPU only, which is several times slower.
|
|
311
|
+
do: On Intel/AMD integrated GPUs Ollama skips the GPU unless you set OLLAMA_IGPU_ENABLE=1 and restart it ...
|
|
312
|
+
ok chat template: accepts a system message after the start.
|
|
313
|
+
PROBLEM thinking: the app's `think: false` is ignored, so the model thinks anyway (19 s for a one-number answer). ...
|
|
314
|
+
do: run your app through `localmend serve`, which sends the server's own no-thinking switch.
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Real output on the test laptop; reading speed varies from run to run.
|
|
318
|
+
</details>
|
|
319
|
+
|
|
320
|
+
Then what your agent actually does with it:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
localmend serve --observe --upstream http://127.0.0.1:11434 # all fixes off, records a trace
|
|
324
|
+
# ... use your agent normally for a few tasks, then stop with Ctrl+C: the report prints ...
|
|
325
|
+
localmend doctor # the same report again, any time (newest trace)
|
|
326
|
+
localmend report # every request, one line each
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Both also take a file: `localmend doctor FILE`, `localmend report FILE`.
|
|
330
|
+
|
|
331
|
+
<details>
|
|
332
|
+
<summary>Example <code>doctor</code> report</summary>
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
151 requests, 12 sessions, 92.1 min of model time
|
|
336
|
+
Re-reading prompts: 28.5 min (31% of model time).
|
|
337
|
+
PROBLEM cache: the system prompt changed 14 time(s) between requests. First change at
|
|
338
|
+
char 21,754 of 22,328 (97% in) ...
|
|
339
|
+
do: run your app through `localmend serve` ...: its prefix fix moves the changing part out ...
|
|
340
|
+
PROBLEM side calls: 16 title request(s) took 6.2 min ...
|
|
341
|
+
do: ... its sidecalls fix turns thinking off and caps the answer for these short requests.
|
|
342
|
+
PROBLEM unverified finish: 14 time(s) the model edited files and tried to finish
|
|
343
|
+
without running anything since.
|
|
344
|
+
do: ... its verify fix asks once to run a check before finishing.
|
|
345
|
+
```
|
|
346
|
+
</details>
|
|
347
|
+
|
|
348
|
+
**Traces contain your full prompts, code and the model's answers.** So `--observe` saves them in
|
|
349
|
+
your own user folder, never in your project (where they could be committed by accident):
|
|
350
|
+
`%LOCALAPPDATA%\localmend\traces` on Windows, `~/Library/Application Support/localmend/traces` on
|
|
351
|
+
macOS, `~/.local/share/localmend/traces` on Linux. One file per run; on Linux and macOS only you can
|
|
352
|
+
read them. `--trace FILE` lets you choose the file. Read a trace before sharing it.
|
|
353
|
+
|
|
354
|
+
## Other ways to do this
|
|
355
|
+
|
|
356
|
+
Some of this you can do without localmend, and some tools do one part of it:
|
|
357
|
+
|
|
358
|
+
- **Claude Code's own switches.** With a Claude model name (`ANTHROPIC_MODEL=claude-sonnet-4-5`) it
|
|
359
|
+
doesn't send the late system message, and `CLAUDE_CODE_ATTRIBUTION_HEADER=0` plus
|
|
360
|
+
`claude --exclude-dynamic-system-prompt-sections` keep its prompt stable. It then sends a bigger
|
|
361
|
+
prompt (~22k tokens instead of ~14k): 62 min for our 15 tasks, against 52 through localmend
|
|
362
|
+
without verify. [Details](https://github.com/rodricksz4h5/localmend/blob/main/docs/RESULTS.md#claude-code).
|
|
363
|
+
- **llama.cpp's `--cache-reuse`** can reuse chunks of a prompt after a change, but not on hybrid
|
|
364
|
+
models like Qwen3.5, and Ollama has nothing like it. Moving the changing text out of the system
|
|
365
|
+
prompt works on every server. If your llama-server runs several slots (`-np`), a new session may also
|
|
366
|
+
land in a slot that holds a different prompt.
|
|
367
|
+
- **A patched chat template** fixes the "System message must be at the beginning" error for one
|
|
368
|
+
model on one server ([one collection](https://huggingface.co/froggeric/Qwen-Fixed-Chat-Templates)).
|
|
369
|
+
|
|
370
|
+
| | finds the cause | fixes it | verify | side calls / thinking |
|
|
371
|
+
|---|---|---|---|---|
|
|
372
|
+
| [cachekeeper](https://github.com/Monem-Benjeddou/cachekeeper) | cache misses, live | no (observe only) | no | no |
|
|
373
|
+
| [local-llm-kv-cache](https://github.com/the-code-foundry/local-llm-kv-cache) | no | saves llama.cpp's cache to disk | no | no |
|
|
374
|
+
| [ollama-nothink-proxy](https://github.com/FreeWizardWu/ollama-nothink-proxy) | no | no | no | thinking off for every request |
|
|
375
|
+
| [Free Claude Code](https://github.com/Alishahryar1/free-claude-code) | no (`fcc-doctor` collects settings for bug reports) | routes 12 agents to 61 providers, free cloud tiers first | no | per-model thinking settings |
|
|
376
|
+
| **localmend** | cache, side calls, thinking, unverified finish, timeouts (`doctor`) | yes | yes | only for side calls and an explicit `think: false` |
|
|
377
|
+
|
|
378
|
+
**What localmend adds:** one tool that both finds and fixes these problems, for any app and any
|
|
379
|
+
local server, with measured results. Free Claude Code solves a different problem (which provider,
|
|
380
|
+
for free) and works with localmend in front of your local server. cachekeeper's live view of cache
|
|
381
|
+
misses is more detailed than ours; use it alongside if that's what you need (it defaults to port
|
|
382
|
+
4141, ours to 4747).
|
|
383
|
+
|
|
384
|
+
## Troubleshooting
|
|
385
|
+
|
|
386
|
+
**Requests return `502`.** The model server isn't running, or llama.cpp is still loading the model.
|
|
387
|
+
localmend picks it up as soon as it answers; check the `--upstream` address (with or without `/v1`).
|
|
388
|
+
|
|
389
|
+
**Ollama gives nonsense, or the agent forgets its tools.** Ollama's default context is 4096 tokens
|
|
390
|
+
and longer prompts are cut silently from the front: an agent's 10k system prompt arrives as 2k. Set
|
|
391
|
+
`OLLAMA_CONTEXT_LENGTH=32768` (or at least 20k). `check` and `serve` warn about this.
|
|
392
|
+
|
|
393
|
+
**Ollama is very slow on an Intel laptop.** On Intel iGPUs Ollama runs on the CPU unless
|
|
394
|
+
`OLLAMA_IGPU_ENABLE=1` (check with `ollama ps`). On our laptop that took prompt reading from 54 to 88
|
|
395
|
+
tokens/s.
|
|
396
|
+
|
|
397
|
+
**The app shows no streaming for some answers.** After an edit with no check yet, verify reads the
|
|
398
|
+
answer in full before passing it on. Apps with a short first-byte timeout may give up first;
|
|
399
|
+
`--no-verify` turns this off.
|
|
400
|
+
|
|
401
|
+
**Claude Code compacts the conversation every turn.** Set `CLAUDE_CODE_MAX_OUTPUT_TOKENS=4096` along
|
|
402
|
+
with `CLAUDE_CODE_MAX_CONTEXT_TOKENS` (see [Claude Code](#claude-code-settings)).
|
|
403
|
+
|
|
404
|
+
**The app gives up while the model is still reading the prompt.** A new session's first request can
|
|
405
|
+
take minutes on a laptop. Raise the app's timeout (Claude Code: `API_TIMEOUT_MS`; Free Claude Code:
|
|
406
|
+
`HTTP_READ_TIMEOUT`). `doctor` reports these give-ups.
|
|
407
|
+
|
|
408
|
+
**A web UI gets `403`.** localmend refuses requests from web pages on other sites. Apps on
|
|
409
|
+
`localhost`, browser extensions and VS Code webviews are allowed; see [SECURITY.md](https://github.com/rodricksz4h5/localmend/blob/main/SECURITY.md).
|
|
410
|
+
|
|
411
|
+
**Something printed "prefix learned a changing part".** When the prefix fix learns a changing part of
|
|
412
|
+
an agent's system prompt, it prints that part once, so nobody's prompt is rewritten silently.
|
|
413
|
+
Learning only happens for agents (requests with tools), never for plain chat apps.
|
|
414
|
+
|
|
415
|
+
## Known limits
|
|
416
|
+
|
|
417
|
+
- `/v1/chat/completions` gets every fix; `/v1/messages` (Claude Code) gets prefix, sysmerge and verify;
|
|
418
|
+
`/v1/responses` (Codex CLI) gets sysmerge only, and `doctor` reads it. Everything else (Ollama's
|
|
419
|
+
native `/api/chat`, embeddings) passes through untouched.
|
|
420
|
+
- The wrap-up budget is per task: a new message from you in the same chat resets it.
|
|
421
|
+
- Ollama ignores `tool_choice`, so there the wrap-up is a request, not a rule. On llama.cpp's
|
|
422
|
+
`/v1/messages` it is only partly kept: in the Claude Code benchmark the model still called a
|
|
423
|
+
tool in 7 of 12 wrap-ups (the next wrap-up then asks again).
|
|
424
|
+
|
|
425
|
+
## FAQ
|
|
426
|
+
|
|
427
|
+
**Why not just tell the agent "run the tests before you finish" (e.g. in AGENTS.md)?** Try
|
|
428
|
+
it: if it works for your model, use `--no-verify`. We haven't measured it against verify
|
|
429
|
+
yet. Verify only steps in when the model edited code and ran nothing since, and only once
|
|
430
|
+
per task.
|
|
431
|
+
|
|
432
|
+
**Does it send anything anywhere?** No. It only talks to the `--upstream` you give it. Traces
|
|
433
|
+
are written only if you ask for one.
|
|
434
|
+
|
|
435
|
+
**Is it safe to run?** It listens on `127.0.0.1` only and refuses requests from web pages on other
|
|
436
|
+
sites. `--host 0.0.0.0` opens it to your network without a password. Details and how to report a
|
|
437
|
+
problem: [SECURITY.md](https://github.com/rodricksz4h5/localmend/blob/main/SECURITY.md).
|
|
438
|
+
|
|
439
|
+
## Status
|
|
440
|
+
|
|
441
|
+
Early. Works with any OpenAI-compatible chat completions server (streaming and non-streaming), and
|
|
442
|
+
with Anthropic Messages servers for Claude Code (tested on llama.cpp and Ollama). All measurements so
|
|
443
|
+
far are from one Windows laptop (Intel iGPU) with Qwen3.5-4B and Gemma 4 E4B; the tests also pass on
|
|
444
|
+
Linux and macOS. More models, apps and machines (Apple Silicon first) are next.
|
|
445
|
+
|
|
446
|
+
## Development
|
|
447
|
+
|
|
448
|
+
```bash
|
|
449
|
+
pip install -e . pytest
|
|
450
|
+
python -m pytest -q # no model server needed
|
|
451
|
+
```
|