Skip to content

Commit 07c9213

Browse files
AlexMikhalevAlexclaude
authored
fix: overhaul tinyclaw context compression and fix 8 bugs (#586)
* fix: overhaul tinyclaw context compression and fix 8 bugs Critical fixes: - compress() now uses proxy-first fallback (proxy -> Ollama -> extractive) instead of always bypassing proxy and going to Ollama directly - Summary is now injected into LLM context after compression via build_proxy_messages() helper with user+assistant pair - proxy_messages built from post-compression session state, not stale pre-compression snapshot that caused context loss Additional fixes: - tools_available() no longer auto-resets failure flag (was defeating the circuit breaker set by tool_call() on error) - Removed dead summarize_at_token_ratio config field - AnthropicUsage uses Anthropic-canonical field names with OpenAI aliases - Removed all #[allow(dead_code)] violations - Made test_text_only_fallback deterministic (unreachable port, not default) 7 new tests covering all changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: stabilize pr-586 on main by resolving ci blockers * ci: decouple rust validation from desktop frontend pipeline * ci: fix python lint env and resolve ontology clippy regressions * fix: resolve rolegraph example clippy failures in CI * fix: remove unused imports and variables in router examples - Remove unused Latency import in advanced_routing.rs - Prefix unused spawner variable with underscore in unified_routing.rs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: replace vec! with arrays in router strategy tests Replace vec! with arrays to satisfy clippy useless_vec lint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: resolve remaining clippy errors in router examples - Replace CostOptimized::default() with CostOptimized (unit struct) - Replace remaining vec! with arrays in strategy.rs tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Alex <alex@example.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2869425 commit 07c9213

23 files changed

Lines changed: 420 additions & 341 deletions

File tree

.beads/issues.jsonl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
{"id":"terraphim-ai-061","title":"Fix tools_available() auto-reset side effect","status":"closed","priority":2,"issue_type":"bug","owner":"alex@example.com","created_at":"2026-02-26T16:28:08.006176745Z","created_by":"Alex","updated_at":"2026-02-26T19:07:04.472260702Z","closed_at":"2026-02-26T19:07:04.472260702Z","close_reason":"Closed"}
12
{"id":"terraphim-ai-2sz","title":"Add embedded device settings fallback to terraphim-cli","description":"Evaluate and implement an embedded DeviceSettings fallback (similar to terraphim-agent) so terraphim-cli doesn't fail on missing settings.","status":"open","priority":2,"issue_type":"task","owner":"alex@metacortex.engineer","created_at":"2026-02-10T08:23:48.689656434Z","created_by":"AlexMikhalev","updated_at":"2026-02-10T08:23:48.689656434Z"}
3+
{"id":"terraphim-ai-8ld","title":"Rewrite compress() with proxy-first fallback","status":"closed","priority":1,"issue_type":"bug","owner":"alex@example.com","created_at":"2026-02-26T16:28:28.794633105Z","created_by":"Alex","updated_at":"2026-02-26T19:07:04.510972897Z","closed_at":"2026-02-26T19:07:04.510972897Z","close_reason":"Closed"}
24
{"id":"terraphim-ai-cbm","title":"Clarify terraphim-agent TUI offline/server requirement","description":"Determine whether terraphim-agent TUI is expected to work fully offline or requires a running server; document requirement and adjust behavior if needed.","design":"Phase 1/2 docs: docs/plans/terraphim-agent-tui-offline-server-research-2026-02-13.md and docs/plans/terraphim-agent-tui-offline-server-design-2026-02-13.md","acceptance_criteria":"Contract for fullscreen TUI vs REPL/offline is explicit in help/docs; actionable messaging when fullscreen TUI server is unreachable; tests cover mode behavior to prevent regressions.","notes":"Implemented on 2026-02-13: mode-contract wording in CLI/docs, fullscreen TUI server preflight with actionable repl fallback, and regression tests for help/non-TTY/server-failure paths. Validation: cargo fmt --package terraphim_agent; cargo clippy -p terraphim_agent --all-targets -- -D warnings; cargo test -p terraphim_agent --test offline_mode_tests; cargo test -p terraphim_agent --test server_mode_tests test_server_mode_config_show; targeted unit tests in main.rs for URL resolution and error messaging.","status":"closed","priority":2,"issue_type":"task","owner":"alex@metacortex.engineer","created_at":"2026-02-10T08:23:40.310825316Z","created_by":"AlexMikhalev","updated_at":"2026-02-23T10:46:13.066528719Z","closed_at":"2026-02-13T14:41:42.09313609Z"}
35
{"id":"terraphim-ai-iwy","title":"Add knowledge graph ranking example and guide","status":"closed","priority":2,"issue_type":"feature","owner":"alex@example.com","created_at":"2026-02-15T11:54:58.063432151Z","created_by":"Alex","updated_at":"2026-02-15T11:58:22.282021161Z","closed_at":"2026-02-15T11:58:22.282021161Z","close_reason":"Created knowledge graph ranking example and guide article"}
6+
{"id":"terraphim-ai-ou6","title":"Make test_text_only_fallback deterministic","status":"closed","priority":2,"issue_type":"bug","owner":"alex@example.com","created_at":"2026-02-26T16:28:23.598516653Z","created_by":"Alex","updated_at":"2026-02-26T19:07:04.509756346Z","closed_at":"2026-02-26T19:07:04.509756346Z","close_reason":"Closed"}
7+
{"id":"terraphim-ai-pdl","title":"Remove all #[allow(dead_code)] annotations","status":"closed","priority":3,"issue_type":"task","owner":"alex@example.com","created_at":"2026-02-26T16:28:39.215892144Z","created_by":"Alex","updated_at":"2026-02-26T19:07:04.513163031Z","closed_at":"2026-02-26T19:07:04.513163031Z","close_reason":"Closed"}
8+
{"id":"terraphim-ai-q63","title":"Remove dead summarize_at_token_ratio config","status":"closed","priority":3,"issue_type":"bug","owner":"alex@example.com","created_at":"2026-02-26T16:28:13.176563141Z","created_by":"Alex","updated_at":"2026-02-26T19:07:04.506195356Z","closed_at":"2026-02-26T19:07:04.506195356Z","close_reason":"Closed"}
9+
{"id":"terraphim-ai-rv5","title":"Fix AnthropicUsage field naming to Anthropic convention","status":"closed","priority":3,"issue_type":"bug","owner":"alex@example.com","created_at":"2026-02-26T16:28:18.370689359Z","created_by":"Alex","updated_at":"2026-02-26T19:07:04.50862237Z","closed_at":"2026-02-26T19:07:04.50862237Z","close_reason":"Closed"}
410
{"id":"terraphim-ai-tcw","title":"Define required feature parity between terraphim-agent and terraphim-cli","description":"Decide which commands/features must exist in both CLIs and document any intentional gaps for automation vs interactive use.","status":"open","priority":3,"issue_type":"task","owner":"alex@metacortex.engineer","created_at":"2026-02-10T08:23:51.548645229Z","created_by":"AlexMikhalev","updated_at":"2026-02-10T08:23:51.548645229Z"}
11+
{"id":"terraphim-ai-yuk","title":"Fix stale data + inject summary into LLM context","status":"closed","priority":0,"issue_type":"bug","owner":"alex@example.com","created_at":"2026-02-26T16:28:34.015795558Z","created_by":"Alex","updated_at":"2026-02-26T19:07:04.512036157Z","closed_at":"2026-02-26T19:07:04.512036157Z","close_reason":"Closed"}

.github/workflows/ci-optimized.yml

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,13 @@ jobs:
134134

135135
lint-and-format:
136136
runs-on: [self-hosted, Linux, X64]
137-
needs: [setup, build-base-image, build-frontend]
137+
needs: [setup, build-base-image]
138138
if: needs.setup.outputs.should-build == 'true'
139139

140140
steps:
141141
- name: Checkout code
142142
uses: actions/checkout@v6
143143

144-
- name: Download frontend artifacts
145-
uses: actions/download-artifact@v4
146-
with:
147-
name: frontend-dist
148-
path: desktop/dist
149-
150144
- name: Download Docker image artifact
151145
uses: actions/download-artifact@v4
152146
with:
@@ -157,10 +151,6 @@ jobs:
157151
run: |
158152
docker load < terraphim-builder-image.tar.gz
159153
160-
- name: Verify frontend dist
161-
run: |
162-
ls -la desktop/dist || echo "No desktop/dist found"
163-
164154
- name: Run format check
165155
run: |
166156
docker run --rm \
@@ -187,7 +177,7 @@ jobs:
187177

188178
build-rust:
189179
runs-on: [self-hosted, Linux, X64]
190-
needs: [setup, build-base-image, build-frontend, lint-and-format]
180+
needs: [setup, build-base-image, lint-and-format]
191181
if: needs.setup.outputs.should-build == 'true'
192182
strategy:
193183
fail-fast: false
@@ -207,12 +197,6 @@ jobs:
207197
- name: Checkout code
208198
uses: actions/checkout@v6
209199

210-
- name: Download frontend artifacts
211-
uses: actions/download-artifact@v4
212-
with:
213-
name: frontend-dist
214-
path: frontend-dist
215-
216200
- name: Download Docker image artifact
217201
uses: actions/download-artifact@v4
218202
with:
@@ -225,10 +209,6 @@ jobs:
225209
226210
- name: Build Rust project
227211
run: |
228-
# Copy frontend dist to desktop/dist (RustEmbed expects ../desktop/dist relative to terraphim_server)
229-
mkdir -p desktop/dist
230-
cp -r frontend-dist/* desktop/dist/ || echo "No frontend files found"
231-
232212
# Build with Docker
233213
docker run --rm \
234214
-v $PWD:/workspace \
@@ -273,7 +253,7 @@ jobs:
273253

274254
test:
275255
runs-on: [self-hosted, Linux, X64]
276-
needs: [setup, build-base-image, build-frontend, build-rust]
256+
needs: [setup, build-base-image, build-rust]
277257
if: needs.setup.outputs.should-build == 'true'
278258
timeout-minutes: 20
279259

@@ -289,12 +269,6 @@ jobs:
289269
- name: Checkout code
290270
uses: actions/checkout@v6
291271

292-
- name: Download frontend artifacts
293-
uses: actions/download-artifact@v4
294-
with:
295-
name: frontend-dist
296-
path: desktop/dist
297-
298272
- name: Download Docker image artifact
299273
uses: actions/download-artifact@v4
300274
with:
@@ -322,7 +296,7 @@ jobs:
322296
"
323297
324298
summary:
325-
needs: [lint-and-format, build-frontend, build-rust, test]
299+
needs: [lint-and-format, build-rust, test]
326300
if: always()
327301
runs-on: [self-hosted, Linux, X64]
328302

.github/workflows/ci-pr.yml

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
frontend-changed: ${{ steps.changes.outputs.frontend }}
2929
dockerfile-changed: ${{ steps.changes.outputs.dockerfile }}
3030
docs-changed: ${{ steps.changes.outputs.docs }}
31-
should-run-full-ci: ${{ steps.changes.outputs.should-run_full_ci }}
31+
should-run-full-ci: ${{ steps.should_run.outputs.should_run_full_ci }}
3232

3333
steps:
3434
- name: Pre-checkout cleanup
@@ -83,13 +83,13 @@ jobs:
8383
echo "should_run_full_ci=false" >> $GITHUB_OUTPUT
8484
fi
8585
86-
# Build frontend (required for RustEmbed)
86+
# Build frontend (frontend-only changes)
8787
build-frontend:
8888
name: Build Frontend
8989
runs-on: [self-hosted, Linux, X64]
9090
timeout-minutes: 20
9191
needs: changes
92-
if: needs.changes.outputs.rust-changed == 'true'
92+
if: needs.changes.outputs.frontend-changed == 'true'
9393

9494
steps:
9595
- name: Pre-checkout cleanup
@@ -165,24 +165,18 @@ jobs:
165165
name: Rust Clippy
166166
runs-on: [self-hosted, Linux, X64]
167167
timeout-minutes: 5
168-
needs: [changes, build-frontend]
168+
needs: [changes]
169169
if: needs.changes.outputs.rust-changed == 'true'
170170

171171
steps:
172172
- name: Pre-checkout cleanup
173173
run: |
174174
WORKDIR="${GITHUB_WORKSPACE:-$PWD}"
175-
sudo rm -rf "${WORKDIR}/target" "${WORKDIR}/desktop/dist" || true
175+
sudo rm -rf "${WORKDIR}/target" || true
176176
177177
- name: Checkout
178178
uses: actions/checkout@v6
179179

180-
- name: Download frontend dist
181-
uses: actions/download-artifact@v4
182-
with:
183-
name: frontend-dist
184-
path: desktop/dist
185-
186180
- name: Install Rust toolchain
187181
uses: dtolnay/rust-toolchain@stable
188182
with:
@@ -196,24 +190,18 @@ jobs:
196190
name: Rust Compilation Check
197191
runs-on: [self-hosted, Linux, X64]
198192
timeout-minutes: 6
199-
needs: [changes, build-frontend]
193+
needs: [changes]
200194
if: needs.changes.outputs.rust-changed == 'true'
201195

202196
steps:
203197
- name: Pre-checkout cleanup
204198
run: |
205199
WORKDIR="${GITHUB_WORKSPACE:-$PWD}"
206-
sudo rm -rf "${WORKDIR}/target" "${WORKDIR}/desktop/dist" || true
200+
sudo rm -rf "${WORKDIR}/target" || true
207201
208202
- name: Checkout
209203
uses: actions/checkout@v6
210204

211-
- name: Download frontend dist
212-
uses: actions/download-artifact@v4
213-
with:
214-
name: frontend-dist
215-
path: desktop/dist
216-
217205
- name: Install Rust toolchain
218206
uses: dtolnay/rust-toolchain@stable
219207
with:
@@ -281,24 +269,18 @@ jobs:
281269
name: Rust Unit Tests
282270
runs-on: [self-hosted, Linux, X64]
283271
timeout-minutes: 8
284-
needs: [changes, rust-compile, build-frontend]
272+
needs: [changes, rust-compile]
285273
if: needs.changes.outputs.rust-changed == 'true' && needs.rust-compile.result == 'success'
286274

287275
steps:
288276
- name: Pre-checkout cleanup
289277
run: |
290278
WORKDIR="${GITHUB_WORKSPACE:-$PWD}"
291-
sudo rm -rf "${WORKDIR}/target" "${WORKDIR}/desktop/dist" || true
279+
sudo rm -rf "${WORKDIR}/target" || true
292280
293281
- name: Checkout
294282
uses: actions/checkout@v6
295283

296-
- name: Download frontend dist
297-
uses: actions/download-artifact@v4
298-
with:
299-
name: frontend-dist
300-
path: desktop/dist
301-
302284
- name: Install system dependencies
303285
run: |
304286
sudo apt-get update -qq
@@ -405,7 +387,7 @@ jobs:
405387
echo "| Job | Status | Notes |" >> $GITHUB_STEP_SUMMARY
406388
echo "|-----|--------|-------|" >> $GITHUB_STEP_SUMMARY
407389
echo "| Changes Detected | ${{ needs.changes.result }} | Rust: ${{ needs.changes.outputs.rust-changed }}, Frontend: ${{ needs.changes.outputs.frontend-changed }} |" >> $GITHUB_STEP_SUMMARY
408-
echo "| Build Frontend | ${{ needs.build-frontend.result || 'skipped' }} | Frontend build for RustEmbed |" >> $GITHUB_STEP_SUMMARY
390+
echo "| Build Frontend | ${{ needs.build-frontend.result || 'skipped' }} | Frontend build (frontend-only changes) |" >> $GITHUB_STEP_SUMMARY
409391
echo "| Rust Format | ${{ needs.rust-format.result || 'skipped' }} | Code formatting check |" >> $GITHUB_STEP_SUMMARY
410392
echo "| Rust Clippy | ${{ needs.rust-clippy.result || 'skipped' }} | Linting and warnings |" >> $GITHUB_STEP_SUMMARY
411393
echo "| Rust Compile | ${{ needs.rust-compile.result || 'skipped' }} | Compilation verification |" >> $GITHUB_STEP_SUMMARY
@@ -414,8 +396,7 @@ jobs:
414396
echo "| WASM Build | ${{ needs.wasm-build.result || 'skipped' }} | WebAssembly compilation |" >> $GITHUB_STEP_SUMMARY
415397
echo "" >> $GITHUB_STEP_SUMMARY
416398
417-
if [[ "${{ needs.build-frontend.result }}" == "failure" ]] || \
418-
[[ "${{ needs.rust-format.result }}" == "failure" ]] || \
399+
if [[ "${{ needs.rust-format.result }}" == "failure" ]] || \
419400
[[ "${{ needs.rust-clippy.result }}" == "failure" ]] || \
420401
[[ "${{ needs.rust-compile.result }}" == "failure" ]] || \
421402
[[ "${{ needs.rust-tests.result }}" == "failure" ]]; then

.github/workflows/python-bindings.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ jobs:
4242
with:
4343
enable-cache: true
4444

45-
- name: Install dependencies
46-
run: uv pip install --system black ruff mypy
47-
4845
- name: Setup virtual environment
4946
working-directory: crates/terraphim_automata_py
5047
run: |
@@ -55,6 +52,7 @@ jobs:
5552
else
5653
source .venv/bin/activate
5754
fi
55+
uv pip install black ruff mypy
5856
5957
- name: Fix Black formatting
6058
working-directory: crates/terraphim_automata_py
@@ -64,16 +62,28 @@ jobs:
6462
else
6563
source .venv/bin/activate
6664
fi
67-
uv run black python/
65+
black python/
6866
continue-on-error: false
6967

7068
- name: Lint with Ruff
7169
working-directory: crates/terraphim_automata_py
72-
run: ruff check python/
70+
run: |
71+
if [[ "$RUNNER_OS" == "Windows" ]]; then
72+
source .venv/Scripts/activate
73+
else
74+
source .venv/bin/activate
75+
fi
76+
ruff check python/
7377
7478
- name: Type check with mypy
7579
working-directory: crates/terraphim_automata_py
76-
run: mypy python/terraphim_automata/ --ignore-missing-imports
80+
run: |
81+
if [[ "$RUNNER_OS" == "Windows" ]]; then
82+
source .venv/Scripts/activate
83+
else
84+
source .venv/bin/activate
85+
fi
86+
mypy python/terraphim_automata/ --ignore-missing-imports
7787
continue-on-error: true
7888

7989
test:

.github/workflows/test-ci.yml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -40,41 +40,6 @@ jobs:
4040
sudo apt-get install -yqq --no-install-recommends \
4141
libappindicator3-dev || true
4242
43-
- name: Setup Node.js
44-
uses: actions/setup-node@v4
45-
with:
46-
node-version: '20'
47-
48-
- name: Cache frontend dependencies
49-
uses: actions/cache@v4
50-
with:
51-
path: |
52-
desktop/node_modules
53-
~/.cache/yarn
54-
key: ${{ runner.os }}-frontend-${{ hashFiles('desktop/yarn.lock') }}
55-
restore-keys: |
56-
${{ runner.os }}-frontend-
57-
58-
- name: Cache frontend build
59-
uses: actions/cache@v4
60-
with:
61-
path: desktop/dist
62-
key: ${{ runner.os }}-frontend-dist-${{ hashFiles('desktop/src/**', 'desktop/package.json', 'desktop/vite.config.ts') }}
63-
restore-keys: |
64-
${{ runner.os }}-frontend-dist-
65-
66-
- name: Build frontend
67-
working-directory: desktop
68-
run: |
69-
# Skip build if dist already exists from cache
70-
if [ -f "dist/index.html" ]; then
71-
echo "Frontend dist found in cache, skipping build"
72-
else
73-
echo "Building frontend..."
74-
yarn install --frozen-lockfile
75-
yarn build
76-
fi
77-
7843
- name: Install Rust toolchain
7944
uses: dtolnay/rust-toolchain@stable
8045
with:

0 commit comments

Comments
 (0)