mpfaffenberger / mpfaffenberger/code_puppy_core_plugins

spill: oversized result is sent to the model un-spilled when no single field exceeds the spill threshold

Open
#26 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3
Forks
20
Avg merge
2d 3h
Merged PRs (30d)
20

Description

Bug

spill/register_callbacks.py — lines 208–225 and 264–265.

The spill plugin only considers a field spillable if it is strictly larger than spill_threshold = min(preview_bytes, cap // 2) (line 222). per_field_limit is derived from len(spillable) (line 225) and the commit is guarded by if total <= cap: (line 264).

A tool result composed of many medium-sized fields — each ≤ threshold, but summing over the cap — leaves spillable empty, per_field_limit == 0, no replacements built, and total never drops. The oversized dict goes straight to the model with nothing spilled, defeating the plugin's only purpose.

Repro (defaults cap=32768, preview_bytes=4096)

12 fields × 3500 bytes = 42,000 bytes → spill_threshold=4096, spillable=0, commit condition False → result untouched.

Suggested fix

When spillable is empty but fixed_bytes alone exceeds the cap, fall back to spilling (or shrinking) the largest fixed fields so something is actually reduced, rather than degrading to "do nothing".

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in spill/register_callbacks.py at lines 208–225 and 264–265, then reproduce the 12-field case with cap=32768 and preview_bytes=4096. Ensure that when no field exceeds the spill threshold but the combined result exceeds the cap, the largest fixed fields are spilled or shrunk and the result sent to the model is within the cap.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.