Skip to content

Tools tab (gh) + prompt caching + conversation compaction#4

Merged
mattmezza merged 5 commits into
mainfrom
feat/tools-tab-and-prompt-caching
Jun 7, 2026
Merged

Tools tab (gh) + prompt caching + conversation compaction#4
mattmezza merged 5 commits into
mainfrom
feat/tools-tab-and-prompt-caching

Conversation

@mattmezza

@mattmezza mattmezza commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Branch bundles several related changes to prompt assembly, history, and tooling.

1. Per-turn datetime + cached static prompt

  • Live date/time injected into each user-message turn (not the static system prompt), so the prefix is stable and cacheable.
  • Session mode: static system prompt snapshotted once per conversation, reused until /new; per-request execution plan moved to the per-turn preamble.
  • Anthropic prompt caching (cache_control) on the system/tools prefix.

2. Tools tab + GitHub CLI (gh)

  • core/tools.py registry: enabled tools are authenticated (env) and advertised to the LLM; disabled tools stay hidden.
  • gh: token stored as tools.gh.token (secret), injected as GH_TOKEN; Tools tab with enable/token/Test; gh installed in the container image.

3. /clear alias

  • /clear now works as an alias for /new (clears the conversation).

4. Conversation compaction (session mode)

  • When the real context size (from provider usageinput + cache_read + cache_creation, model-agnostic, no tokenizer) crosses a threshold, the oldest turns are summarized by a small model and recent turns kept verbatim. Client-side so it works across all providers; never splits a tool_use from its tool_result.
  • Threshold configurable in the History tab (% of context window or absolute tokens, + keep-recent-turns); compaction model in the LLM tab.
  • User is notified with a system message when compaction triggers (delivered as a separate follow-up via AgentResponse.system_notice on Telegram/WhatsApp).

Tests

tests/test_tools.py (13) + tests/test_compaction.py (14) added; full suite 252 passed. Lint clean.

🤖 Generated with Claude Code

mattmezza and others added 5 commits June 7, 2026 20:42
- Inject live date/time into each user-message turn instead of the static
  system prompt, so the prompt prefix is stable and cacheable.
- Snapshot the static system prompt once per session (session mode) and reuse
  it until /new, instead of rebuilding and re-sending it every turn.
- Move the per-request execution plan out of the static prompt into the
  per-turn preamble.
- Add Anthropic prompt caching (cache_control) on the system/tools prefix.
- Add a Tools tab + tools config registry (core/tools.py); first tool is the
  GitHub CLI (gh): GH_TOKEN auth, prompt advertisement when active, token test
  endpoint, and gh installed in the container image.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Add /clear as an alias for /new (clears conversation context).
- Add client-side conversation compaction for session mode: when the real
  context size (from provider usage) crosses a threshold, summarize the oldest
  turns with a small model and keep recent turns verbatim. Works across all
  providers (no server-side compaction dependency); never splits a tool_use
  from its tool_result.
- Capture token usage (input/output/cache → context_tokens) in LLMResponse for
  both Anthropic and OpenAI-compatible providers.
- Threshold configurable in the History tab (% of context window or absolute
  tokens, plus keep-recent-turns); compaction model configurable in the LLM tab.
- Notify the user with a system message when compaction triggers (delivered as
  a separate follow-up on Telegram/WhatsApp via AgentResponse.system_notice).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mattmezza mattmezza changed the title Per-turn datetime, cached static prompt, Tools tab (gh CLI) Tools tab (gh) + prompt caching + conversation compaction Jun 7, 2026
@mattmezza mattmezza merged commit 0870df7 into main Jun 7, 2026
1 check passed
@mattmezza mattmezza deleted the feat/tools-tab-and-prompt-caching branch June 7, 2026 19:37
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