code-yeongyu / code-yeongyu/senpi

Context reduction alternates payload shapes around the 50% gate

Open
#900 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
429
Forks
98
Avg merge
5h 3m
Merged PRs (30d)
526

Description

## Summary

Senpi's builtin request-local context reduction is gated statelessly at 50% of
the context window. When provider-reported usage moves just above and below that
boundary while stored session history is unchanged, consecutive requests
alternate between reduced and unreduced payload shapes. That defeats stable
prompt-prefix reuse.

## Reproduction

On v2026.8.14, a deterministic generated fixture uses:

- a 1,000,000-token context window;
- 507 request-local context evaluations;
- 319 transitions across the gate using 501,000 and 499,000 reported tokens;
- generated old tool-call results that the real builtin reducer can clear.

Hashing the fully serialized outgoing message list on each evaluation produces
two distinct hashes on stock v2026.8.14. The fixture models threshold exposure;
it does not attribute cache cost or overhead to the number of evaluations.

## Expected behavior

After request-local reduction first engages, keep it engaged until an accepted
persisted compaction changes the stored history. That yields one outgoing
payload shape across the fixture. Provider-native compaction paths must continue
to bypass Senpi reduction.

This follows the stateful cache-stability approach already used for emergency
pruning in #425. Numeric release hysteresis alone is insufficient here because
a successful request-local reduction can make the next reported usage fall well
below a narrow release band without changing stored history.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the deterministic fixture described in the issue on v2026.8.14 and inspect the request-local context reduction path alongside the emergency-pruning approach in #425. Done means reduction remains engaged until accepted persisted compaction changes stored history, the fixture produces one serialized payload shape, and provider-native compaction still bypasses Senpi reduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.