Skip to content

fix: overhaul tinyclaw context compression and fix 8 bugs#586

Merged
AlexMikhalev merged 8 commits into
mainfrom
dependabot/cargo/regex-1.12.3
Feb 27, 2026
Merged

fix: overhaul tinyclaw context compression and fix 8 bugs#586
AlexMikhalev merged 8 commits into
mainfrom
dependabot/cargo/regex-1.12.3

Conversation

@AlexMikhalev

Copy link
Copy Markdown
Contributor

Summary

  • Critical: Fix broken context compression -- compress() now uses proxy-first fallback (proxy -> Ollama -> extractive) instead of always bypassing the proxy and going to Ollama directly
  • Critical: Fix summary injection -- After compression, the summary is now actually injected into the LLM context via a new build_proxy_messages() helper. Previously, compression stored the summary but never used it, actively destroying context.
  • Critical: Fix stale data bug -- proxy_messages is now built from post-compression session state instead of a stale pre-compression snapshot
  • Fix tools_available() auto-reset -- The getter no longer has a side effect that resets the failure flag, which was defeating the circuit breaker
  • Remove dead config -- summarize_at_token_ratio field removed (was never read)
  • Fix AnthropicUsage field naming -- Uses Anthropic-canonical names (input_tokens/output_tokens) with OpenAI aliases
  • Remove #[allow(dead_code)] -- All violations removed per project rules
  • Fix flaky test -- test_text_only_fallback is now deterministic (uses unreachable port)
  • Dep bumps -- regex 1.12.2 -> 1.12.3, uuid 1.19.0 -> 1.21.0

Test plan

  • cargo fmt -p terraphim_tinyclaw -- --check clean
  • cargo clippy -p terraphim_tinyclaw zero warnings
  • cargo test -p terraphim_tinyclaw --lib -- 108 passed, 0 failed
  • cargo test --workspace --lib -- all passing
  • Manual test: send messages via Telegram, verify compression uses proxy when available
  • Manual test: verify summary context is preserved across compression boundary

Generated with Terraphim AI

Alex and others added 2 commits February 26, 2026 23:40
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>
@AlexMikhalev AlexMikhalev force-pushed the dependabot/cargo/regex-1.12.3 branch from b5b62fc to 6f8fe99 Compare February 26, 2026 22:41
AlexMikhalev and others added 6 commits February 27, 2026 08:04
- 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>
Replace vec! with arrays to satisfy clippy useless_vec lint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 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>
@AlexMikhalev AlexMikhalev merged commit 07c9213 into main Feb 27, 2026
41 of 46 checks passed
@AlexMikhalev AlexMikhalev deleted the dependabot/cargo/regex-1.12.3 branch February 27, 2026 11:13
AlexMikhalev added a commit that referenced this pull request Apr 25, 2026
* 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>
AlexMikhalev added a commit that referenced this pull request May 1, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant