Skip to content
C.W.K.
Lesson 05 of 05 · published

No Cap Without a Door or a Failure

~16 min · limits, truncation, testing, llm-agents, design-rules

Level 0Closed Lens
0 XP0/45 lessons0/13 achievements
0/100 XP to next level100 XP to go0% complete

The Caps Nobody Asked For

Code written by careful engineers, human or model, fills with small limits: 200 characters a line, 500 for a reason, a max_tokens on every call, a maxLength in every schema. Each one looks like hygiene. On Oriel's play path, they turned out to be bugs waiting for a long enough sentence. A notebook line cut at 200 characters lost its last words in every turn (seven of the 55 live lines did). A course's 220-character brief lost its ending on the way to the screen. A keep_ms past its limit was shortened without a word. And a schema's maxLength on her own words told the model what to write, because a brain reads a schema's number as the rule.

Dad's words on 2026-11-11 are the rule itself: please stop putting in unnecessary limits; caps like max_tokens have only ever made latent bugs and never helped. And earlier that evening: why do you keep putting in limits like 200 characters?

The Rule

Nothing Pippa writes or reads on the play path is held to a length Oriel guessed. A bound exists only in two cases:

  • A door that is not Oriel's sets it. cwkPippa's play door takes 60 notebook lines and refuses a 61st whole, its helper door takes 60,000 characters, the family app door answers 2,000 characters, the native client's buffer holds 64 steps.
  • A recorded failure put it there. A look's token budget exists because a small task once replayed 395k tokens a turn, and a play turn takes a look every few seconds. The reflector writes three lessons and two strikes a run because the notebook once grew to 123 lines arguing with each other.

And whatever the bound, it never cuts in silence. What does not fit is refused with the number, left out whole and counted, named by its id, or sent in parts. A list too long for the 2,000-character door is read in pages; a single line longer than a page is read in parts and joined again, never trimmed.

What Was Removed, What Was Kept

Removed (a guess, nothing behind it)Kept (and what holds it)
200 characters a notebook line60 lines a turn: cwkPippa's play door. Dad's lines first, the note says how many were left out and whose
60 a map name, 160 a marka look's token share: a long name rides by its id
500 characters of Dad's approving words600 characters of Pippa Home's entry: Home's door. Dad's words stay whole in Oriel's record
300 and 600 of her spoken line60,000 characters a helper prompt: the oldest notes are left out and counted, never the tail cut
maxLength on tool schemas64 steps, 30 s a step, 60 s in all: the native client's wire shape and dead man's grip, refused with the number

One detail in the helper prompt shows why "never cut the tail" matters. The old cut took the end off the prompt, and the end was her notebook: the most important part was the part that silently went missing.

A Test That Keeps the Next Cap From Arriving Unnamed

Rules in prose fade. This one is a test. backend/tests/test_play_limits.py walks every play-path module, finds every upper-case constant whose name looks like a bound (MAX, LIMIT, CHARS, SHOWN, KEPT, CAP, LINES), and fails unless each one is named in a KEPT table with its door or its failure. It also fails if the table names a bound that no longer exists, so the table cannot rot. A second test fails if max_tokens appears anywhere on the play path. Other tests write lines of hundreds of characters, Korean included, and check they read back whole through every door.

The next engineer who reaches for LINE_MAX = 200 does not need to remember any of this. The suite turns red and the message tells them what to do: name the door or the failure, or remove the cap.

Code

Every bound must name its door or its failure (trimmed excerpt, backend/tests/test_play_limits.py)·python
KEPT = {
    # cwkPippa's doors (a request past one is refused whole, and Oriel then plays without it).
    "notebook.DOOR_LINES": "cwkPippa's play door takes 60 notebook lines (EnginePlay.notebook); what is left out is said",
    "solo_helpers.DOOR_PROMPT_MAX": "cwkPippa's helper door takes 60,000 characters (EngineHelper.prompt); the oldest "
                                    "notes are left out and counted, never the tail cut",
    # The native client's wire shape (oriel-hands.m mirrors each; refused loudly).
    "hands.SEQ_STEPS_MAX": "the client's sequence buffer",
    # Three lessons a run: the notebook grew to 123 lines against each other (Coop 1111-17).
    "explore.LESSONS_MAX": "the notebook's 123 contradicting lines (Coop 1111-17); extra ones are counted",
    # ...
}
NAMED = re.compile(r"(MAX|LIMIT|CHARS|SHOWN|KEPT|CAP|LINES)")


def test_every_bound_on_the_play_path_names_its_door_or_its_recorded_failure():
    found = _constants()
    unnamed = sorted(set(found) - set(KEPT))
    assert not unnamed, (f"new bound(s) on the play path: {unnamed}. No preemptive caps (Coop 1111-19): a bound needs "
                         "the door it answers to or the recorded failure it fixes, named in KEPT here and in "
                         "docs/ORIEL-ARCHITECTURE.md; never a silent cut.")
    gone = sorted(set(KEPT) - set(found))
    assert not gone, f"KEPT names bounds that no longer exist: {gone}"


def test_no_model_call_on_the_play_path_caps_its_answer():
    for path in sorted(BACKEND.glob("*.py")):
        if path.stem.startswith(PREFIXES):
            assert "max_tokens" not in path.read_text(encoding="utf-8"), path.name
A line longer than a page is sent in numbered parts and joined again, never trimmed (runnable sketch)·python
PAGE = 40


import re

PART = re.compile(r"^(#\d+) \(part (\d+) of (\d+)\) (.*)$", re.S)
ESC = "\\"                              # a plain line that could be mistaken for a part is escaped


def parts(key, line, page=PAGE):
    if PART.match(line) or line.startswith(ESC):
        line_out = ESC + line
    else:
        line_out = line
    if len(line_out) <= page:
        return [line_out]
    digits = 1
    while True:                          # the label's own width counts against the page
        room = page - len(f"{key} (part {'9' * digits} of {'9' * digits}) ")
        chunks = [line[i:i + room] for i in range(0, len(line), room)]
        if len(str(len(chunks))) <= digits:
            break
        digits += 1
    return [f"{key} (part {i} of {len(chunks)}) {c}" for i, c in enumerate(chunks, 1)]


def joined(sent):
    out, pending = [], []
    for item in sent:
        if item.startswith(ESC):         # an escaped plain line: drop the escape, keep the words
            out.append(item[len(ESC):])
            continue
        part = PART.match(item)
        if not part:
            out.append(item)
            continue
        i, of, chunk = int(part.group(2)), int(part.group(3)), part.group(4)
        pending.append(chunk)
        if i == of:
            out.append("".join(pending))
            pending = []
    return out


line = "phase two starts when the dark mass rises, stay behind his right leg and do not roll forward. " * 3
sent = parts("#17", line)
print(len(sent), "parts, each at most", max(len(s) for s in sent), "characters")
assert joined(sent) == [line]
print("read back whole")

External links

Exercise

Search a project of your own for length caps: string slices like [:200], max_tokens, maxLength, MAX_ constants. For each one, write which door or recorded failure it answers to, or mark it as a guess. Then write the guard test: use ast to find cap-shaped constants and fail on any not listed with a reason. How many of your caps were guesses?
Hint
A slice like text[:200] is a cap even without a named constant. Your test can look for ast.Subscript nodes with a constant upper bound, and the reasons belong next to the code, not in a separate doc.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign in — Please sign in to comment.

No comments yet — be the first.