Skip to content

feat(serve): --compress-tools for MCP tool-description byte-budgeted drop#200

Merged
Delqhi merged 1 commit into
mainfrom
feat/issue-173
Jun 16, 2026
Merged

feat(serve): --compress-tools for MCP tool-description byte-budgeted drop#200
Delqhi merged 1 commit into
mainfrom
feat/issue-173

Conversation

@Delqhi

@Delqhi Delqhi commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Closes #173

Implements issue #173: add a --compress-tools flag to sin-code serve that shrinks the 47 MCP tool descriptions on the wire, without changing tool names, schemas, or behavior.

What is new

Package cmd/sin-code/internal/mcpcompress/ — ponytail-tag compressor with five canonical Rules:

Tag Rule Drops
delete DeleteHedges pleasantries / hedge adverbs ("safely", "carefully", ...)
stdlib StdlibPatterns redundant (via stdlib) parentheticals; Go stdlib … adjectives
native DropTrimEncouragement M6 tail clauses Always prefer over native X / Prefer sin_X over native Y
yagni YagniPatterns speculative (experimental) / (TBD) / (reserved) parentheticals
shrink ShrinkExamples redundant (e.g. …) / (such as …) parenthetical examples

Three new serve flags:

  • --compress-tools — apply default full tag set
  • --compress-tags <csv> — comma-separated override (e.g. delete,yagni,shrink)
  • --print-stats — emit per-tool byte-budget table to stderr

Byte-stability

Every Rule, the Pipeline, and the post-pipeline Normalize are deterministic and idempotent. The compressor_test.go golden suite pins the wire bytes — prerequisite for the system-prompt hash metric (issue #2). Adding the 6th rule is non-breaking; renaming a tag/rule is a major bump (per AGENTS.md §10).

Tool-name safety

The 47 MCP tool Name fields are public API (AGENTS.md §10) and are NEVER modified. CompressSpec asserts this in TestCompressSpec_NameMutable.

Live JSON-RPC smoke test (47 tools, default tag set)

tool orig comp saved ratio
sin_execute 80 73 7 8.8%
sin_read 200 167 33 16.5%
sin_write 194 160 34 17.5%
sin_edit 474 441 33 7.0%
TOTAL (47) 3977 3870 107 2.7%

43 other tools' descriptions don't match any conservative pattern and stay byte-identical.

Verification

gofmt -l cmd/sin-code/internal/mcpcompress/                              clean
go build ./...                                                            clean
go vet ./cmd/sin-code/...                                                 clean
go test -race -count=1 ./cmd/sin-code/internal/mcpcompress/ -v            PASS (+ 14 sub-tests)
go test -race ./cmd/sin-code/internal (serve subset)                     PASS
golangci-lint run ./cmd/sin-code/internal/mcpcompress/                   0 issues
govulncheck ./cmd/sin-code/internal/mcpcompress/...                      No vulns
gosec -no-fail -fmt sarif ./cmd/sin-code/internal/mcpcompress/...         clean
python3 scripts/validate_skill.py --all-bundled --strict                 34/34 OK
/tmp/sin-code-test serve --help | grep -- --compress-tools               present

Docs

  • AGENTS.md §6 — new mcpcompress/ package listed
  • AGENTS.md §8 — (next) → v3.19.0, header bumped to v3.19.0
  • AGENTS.md §10 — new Ponytail tag set subsection
  • CHANGELOG.md — Unreleased entry with savings table

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sin-code Ready Ready Preview, Comment, Open in v0 Jun 16, 2026 7:32pm

Adds a ponytail-tag compressor that shrinks the 47 MCP tool descriptions
in serve's tools/list manifest, without changing tool names, schemas,
or behavior (AGENTS.md §10).

Package: cmd/sin-code/internal/mcpcompress/
Rules (5, ponytail tags):
  delete    -> DeleteHedges        (pleasantries: safely, carefully, ...)
  stdlib    -> StdlibPatterns      ((via stdlib), Go stdlib ...)
  native    -> DropTrimEncouragement (M6 tail clause: Always prefer over native X)
  yagni     -> YagniPatterns       ((experimental), (TBD), reserved)
  shrink    -> ShrinkExamples      ((e.g. ...), (such as ...))

Flags added to 'sin-code serve':
  --compress-tools  : apply the default full set
  --compress-tags   : comma-separated override (e.g. 'delete,yagni,shrink')
  --print-stats     : per-tool byte-budget table to stderr

Byte-stability:
  Every Rule, the Pipeline, and the post-pipeline Normalize are
  deterministic and idempotent. The compressor_test.go golden suite
  is the canonical pin for stable wire bytes -- prerequisite for the
  system-prompt hash metric (issue #2).

Real-world impact (live JSON-RPC smoke test):
  sin_execute  80 -> 73 bytes  (-7,  8.8%)
  sin_read    200 -> 167 bytes (-33, 16.5%)
  sin_write   194 -> 160 bytes (-34, 17.5%)
  sin_edit    474 -> 441 bytes (-33,  7.0%)
  TOTAL      3977 -> 3870      (-107, 2.7%)
  43 other tools uncompressed (no rule matches -> unchanged).

AGENTS.md: §6 (new mcpcompress/ pkg), §10 (ponytail tag contract),
            §8 (v3.19.0 row), header (last verified v3.19.0).
CHANGELOG: Unreleased entry with savings table.

Verification (gates green):
  gofmt -l  cmd/sin-code/internal/mcpcompress/   clean
  go build ./...                                 clean
  go vet   ./cmd/sin-code/...                    clean
  go test  -race -count=1 ./cmd/sin-code/internal/mcpcompress/   PASS
  go test  -race ./cmd/sin-code/internal/ (serve subset)          PASS
  golangci-lint run ./cmd/sin-code/internal/mcpcompress/           0 issues
  govulncheck ./cmd/sin-code/internal/mcpcompress/...             No vulns
  gosec     -no-fail -fmt sarif ./cmd/sin-code/internal/mcpcompress/  clean
  python3 scripts/validate_skill.py --all-bundled --strict        34/34 OK
@github-actions

Copy link
Copy Markdown

🏆 CEO Audit — A+ (100.0/100)

Metric Value
Grade A+
Score 100.0/100
Critical findings 0
High findings 0
Profile QUICK
Min grade gate B

📥 Download full report (Markdown)
📊 Download SARIF (for Code Scanning)

Run ~/.config/opencode/skills/ceo-audit/scripts/audit.sh . --profile=QUICK locally to reproduce.

@github-actions

Copy link
Copy Markdown

🏆 CEO Audit — A+ (100.0/100)

Metric Value
Grade A+
Score 100.0/100
Critical findings 0
High findings 0
Medium findings 0
Profile QUICK
Min grade gate B

📥 Download full report (Markdown)

Run ID: 27642846894 · Commit: ${github.sha}

Run ~/.config/opencode/skills/ceo-audit/scripts/audit.sh . --profile=QUICK locally to reproduce.

@Delqhi
Delqhi deleted the feat/issue-173 branch June 16, 2026 20: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.

feat(serve): add --compress-tools flag for MCP tool-description compression (caveman-shrink analog)

1 participant