[PR #2875] [CLOSED] serve: "skills_compact" (opt-in) keeps opencode's skill list to names and first sentences #4308

Closed
opened 2026-11-07 15:34:46 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2875
Author: @zsariboga
Created: 10/17/2026
Status: ❌ Closed

Base: main ← Head: pr-skills-compact


📝 Commits (1)

  • 0a85dd0 serve: "skills_compact" (opt-in) keeps opencode's skill list to names and first sentences (system message 21,651 -> 16,259 tokens)

📊 Changes

4 files changed (+125 additions, -2 deletions)

View changed files

📝 docs/DETAILS.md (+7 -0)
📝 serve/frontend.py (+39 -2)
📝 serve/server.py (+4 -0)
➕ serve/test_skills_compact.py (+75 -0)

📄 Description

What it changes

opencode lists every installed skill in its system message, inside <available_skills>, with the whole description and
the file location of each. With 58 skills installed that list was ~32K characters, ~43% of the system message. The
skill tool loads a skill by name with its full text, so the list only has to tell the skills apart.

With "skills_compact": true in the config, openai_to_messages and anthropic_to_messages rewrite that block before
the template sees it: each <description> keeps its first sentence (at most 160 characters, cut at a word with ...
when there is no sentence end in reach), and each <location> line is dropped. Every skill's <name> stays. It runs
next to env_to_user (same place, same shape), and it is deterministic, so the prefix cache keeps working.

What it leaves alone

  • Off by default: with the key absent or false, the messages are untouched (a test checks the text is identical).
  • Only the first system message, only between <available_skills> and </available_skills>; a prompt without that
    block is unchanged.
  • No engine change.

Measured

A captured opencode 1.18.7 request (build agent, 58 skills, 15 tools), counted with the model's tokenizer: system
message 21,651 -> 16,259 tokens (-5,392, -25%). On an RTX 5070 Ti Laptop (12 GB) with Swift 1.5 IQ3_XXS that is about
3 s less to read for every session whose system prompt the prefix cache does not already hold. Every skill name is
kept. On by default in our fork's config since 2026-10-13.

How it was checked

  • serve/test_skills_compact.py (6 tests): off changes nothing; first sentence kept, location dropped, names kept,
    text around the block kept; a long sentence is cut at a word; the same list gives the same text; no block, no
    change; the Anthropic path too.
  • serve.test_skills_compact, serve.test_env_to_user, serve.test_frontend: 37 tests OK.
  • docs/DETAILS.md: one entry next to env_to_user.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2875 **Author:** [@zsariboga](https://github.com/zsariboga) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr-skills-compact` --- ### 📝 Commits (1) - [`0a85dd0`](https://github.com/Niko1221/Strata/commit/0a85dd0176c023e5dd5ba92f63102c115d2c13a7) serve: "skills_compact" (opt-in) keeps opencode's skill list to names and first sentences (system message 21,651 -> 16,259 tokens) ### 📊 Changes **4 files changed** (+125 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+7 -0) 📝 `serve/frontend.py` (+39 -2) 📝 `serve/server.py` (+4 -0) ➕ `serve/test_skills_compact.py` (+75 -0) </details> ### 📄 Description ## What it changes opencode lists every installed skill in its system message, inside `<available_skills>`, with the whole description and the file location of each. With 58 skills installed that list was ~32K characters, ~43% of the system message. The skill tool loads a skill by name with its full text, so the list only has to tell the skills apart. With `"skills_compact": true` in the config, `openai_to_messages` and `anthropic_to_messages` rewrite that block before the template sees it: each `<description>` keeps its first sentence (at most 160 characters, cut at a word with ` ...` when there is no sentence end in reach), and each `<location>` line is dropped. Every skill's `<name>` stays. It runs next to `env_to_user` (same place, same shape), and it is deterministic, so the prefix cache keeps working. ## What it leaves alone - Off by default: with the key absent or `false`, the messages are untouched (a test checks the text is identical). - Only the first system message, only between `<available_skills>` and `</available_skills>`; a prompt without that block is unchanged. - No engine change. ## Measured A captured opencode 1.18.7 request (build agent, 58 skills, 15 tools), counted with the model's tokenizer: system message 21,651 -> 16,259 tokens (-5,392, -25%). On an RTX 5070 Ti Laptop (12 GB) with Swift 1.5 IQ3_XXS that is about 3 s less to read for every session whose system prompt the prefix cache does not already hold. Every skill name is kept. On by default in our fork's config since 2026-10-13. ## How it was checked - `serve/test_skills_compact.py` (6 tests): off changes nothing; first sentence kept, location dropped, names kept, text around the block kept; a long sentence is cut at a word; the same list gives the same text; no block, no change; the Anthropic path too. - `serve.test_skills_compact`, `serve.test_env_to_user`, `serve.test_frontend`: 37 tests OK. - `docs/DETAILS.md`: one entry next to `env_to_user`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:34:46 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4308
No description provided.