Skip to content

feat: cache hit observability, configurable TTL, optimized marker stripping#2

Open
binhex wants to merge 9 commits into
nnocte:mainfrom
binhex:main
Open

feat: cache hit observability, configurable TTL, optimized marker stripping#2
binhex wants to merge 9 commits into
nnocte:mainfrom
binhex:main

Conversation

@binhex

@binhex binhex commented Jul 16, 2026

Copy link
Copy Markdown

What's Changed

Three improvements to the opencode-go cache extension (v0.4.0):

📊 Cache hit observability (TUI footer)

  • New message_end hook parses Pi's normalized usage to extract cache hit data
  • Footer shows live cumulative (CU) and turn-based (TB) cache hit percentages
    (e.g. opencode-go-cache: CU98% TB100%)
  • Cumulative average tracks total savings over the session; per-message shows
    how much of the latest response came from cache
  • Verified working live against the real gateway — cacheRead > 0 confirmed

⚙️ Configurable TTL (PI_OPENCODE_CACHE_TTL)

  • Env var replaces the hardcoded "1h" default
  • Accepts values like "30m", "2h", or "0"/"off" to omit ttl entirely
  • Invalid values warn and fall back to "1h"
  • Tightened regex to reject nonsensical zero-TTL values ("0h", "00m")

⚡ Optimized marker stripping

  • Replaced recursive tree walk with non-recursive targeted clear
  • Checks only known marker surfaces (content parts, system blocks, tool defs)
  • Added nested tool_result content clearing for round-tripped markers
  • ~25 fewer lines, same correctness

🌐 OpenCode Zen support

  • Provider gate changed from single "opencode-go" to ["opencode-go", "opencode-zen"]
  • Extension now works with both Go and Zen gateways (same Anthropic-standard cache fields)

Other

  • README updated with new features and verified-live results
  • QA configs added: ESLint, Prettier, pre-commit
  • Code-reviewed by two independent models, all issues fixed

binhex added 9 commits July 16, 2026 21:11
…rker stripping

Three improvements to the opencode-go cache extension:

- Cache hit observability: message_end hook parses assistant message usage
  and shows cumulative cache hit percentage in TUI footer
  (e.g. 'opencode-go-cache: 87%')

- Configurable TTL: PI_OPENCODE_CACHE_TTL env var replaces hardcoded 1h
  default. Supports values like '30m', '2h', '0'/'off' to omit ttl.

- Optimized marker stripping: replaced recursive tree walk with
  non-recursive targeted clear at known marker surfaces, including
  nested tool_result content.

Version bumped to 0.4.0. QA configs (eslint, prettier, pre-commit)
auto-generated.
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