b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
"""User-facing summaries for manual compression commands."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Sequence
|
|
|
|
|
|
def summarize_manual_compression(
|
|
before_messages: Sequence[dict[str, Any]],
|
|
after_messages: Sequence[dict[str, Any]],
|
|
before_tokens: int,
|
|
after_tokens: int,
|
|
) -> dict[str, Any]:
|
|
"""Return consistent user-facing feedback for manual compression."""
|
|
before_count = len(before_messages)
|
|
after_count = len(after_messages)
|
|
noop = list(after_messages) == list(before_messages)
|
|
|
|
if noop:
|
|
headline = f"No changes from compression: {before_count} messages"
|
|
if after_tokens == before_tokens:
|
|
token_line = (
|
|
f"Approx request size: ~{before_tokens:,} tokens (unchanged)"
|
|
)
|
|
else:
|
|
token_line = (
|
|
f"Approx request size: ~{before_tokens:,} → "
|
|
f"~{after_tokens:,} tokens"
|
|
)
|
|
else:
|
|
headline = f"Compressed: {before_count} → {after_count} messages"
|
|
token_line = (
|
|
f"Approx request size: ~{before_tokens:,} → "
|
|
f"~{after_tokens:,} tokens"
|
|
)
|
|
|
|
note = None
|
|
if not noop and after_count < before_count and after_tokens > before_tokens:
|
|
note = (
|
|
"Note: fewer messages can still raise this estimate when "
|
|
"compression rewrites the transcript into denser summaries."
|
|
)
|
|
|
|
return {
|
|
"noop": noop,
|
|
"headline": headline,
|
|
"token_line": token_line,
|
|
"note": note,
|
|
}
|