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

A Little Text and One Picture

~14 min · token-budget, tool-contract, context-window, eyes, api-design

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

A Look Lands in Someone's Context

When Pippa looks through Oriel, the answer does not go to a screen. It goes into the context of the model turn that asked: a picture and some text that the model must read, every token of it, before it can answer Dad. Context is the one resource a long conversation cannot get back. A look that returns three pictures and a page of JSON is not three times more helpful than one that returns one picture; it is three times more expensive, every time, in the one place the cost compounds.

So Oriel's tool contract for the eyes is unusually strict, and it is stated in the first lines of backend/looks.py: every answer is a little text and at most one JPEG; each action has a per-call token budget, image and text together; the answer states its cost; and a test holds every budget.

The Actions and Their Prices

A brain can ask for five reads (plus one more for the watch-along notes, which the last track covers):

ActionWhat it readsPictureBudget (tokens)
looknow: both decks side by side, or one input1536×648 or 1280×7201,600
replaythe last N seconds (20 by default, 120 at most): up to nine keyframes with the most changea 3×3 sheet, 1536×8642,100
cropa region of the original full-resolution frame, for small textat most 1024×10241,600
framethe exact frame at a given time in any sessionas look1,600
sessionsthe list of recorded sessionsnone1,200

A play look that carries Dad's spoken words has its own row, play_look, at 2,100: the same picture as look and room for his lines, whole. It is not an action a brain can ask for, and it sits exactly at cwkPippa's own ceiling for a look, never above.

Why a Ceiling at All

The budgets come from a principle in Pippa's own notes about her largest vessel. A model with a very large context window is pulled toward monolithic designs: "just send everything, there is room". The family's counter-rule is to design every surface for the smaller windows of the other brains, and to treat context as a cost to be stated rather than a space to be filled. Oriel's eyes are where that rule is most concrete, because a picture is the most expensive thing a tool can return.

There is also a reason that has nothing to do with money. A small, predictable answer is easier for any model to use. One picture with a short line saying what was read ("game left, camera right", the moment it shows, the deck it came from) gives the model a clear object to reason about. A heap of frames invites it to describe all of them.

What Every Answer Carries

Beyond the picture, each answer carries a few fixed things: what was read and at which moment; any note the reader needs to trust it (a fallback that stood in for an absent device, a frame too old to call "now"); the cost (image_tokens, budget, total_tokens); and a look_id. The id matters later: cwkPippa keeps every picture a look returns, so Dad can see exactly what Pippa saw, and asks Oriel by that id whether the picture shows a person who should not leave the house.

One more field rides every look by default: the spoiler guard. When Dad plays a game for the first time, he guesses the lore himself, so Pippa's hints climb a ladder: a hint first, then the pattern, and the answer only when he asks. It is one short constant line in every look's answer, because the place to remind a model of a rule is the moment it is about to need it.

Code

The contract and the budgets (trimmed excerpt, backend/looks.py)·python
"""Pippa's eyes: what a look reads, what it returns, and what it costs.

Every answer is a little text and at most one JPEG, the shape cwkPippa's
device looks already deliver to every vessel. Each action has a per-call
token budget (vault principle ``large-ctx-design-bias``): the image's cost by
the most expensive vendor formula plus the text's, stated in the answer and
held by ``tests/test_look_budgets.py``. A look answers the turn that asked and
nothing else; Oriel writes nothing into Master Chief.
"""

# Per-call ceilings in tokens, image and text together.
BUDGETS = {"look": 1600, "replay": 2100, "crop": 1600, "frame": 1600, "sessions": 1200, "watch": 9000,
           "play_look": 2100}
ACTIONS = tuple(sorted(row for row in BUDGETS if row != "play_look"))

LOOK_ONE = (1280, 720)
LOOK_BOTH = (1536, 648)
SHEET_TILE = (512, 288)
SHEET_COLUMNS = 3
CROP_MAX = (1024, 1024)
HINT_LADDER = "Spoilers guarded: hint, then pattern, answer only on Dad's ask; first playthrough, he guesses lore first."
An answer that states its own cost (runnable sketch of the shape)·python
import json
import math


def text_tokens(text):
    return math.ceil(len(text) / 3)          # conservative: three characters a token


def answer(action, read, image_tokens, budget, **fields):
    body = {"action": action, "read": read, **fields,
            "cost": {"image_tokens": image_tokens, "budget": budget, "total_tokens": 0}}
    for _ in range(5):                       # the stated total is part of the text it prices
        total = image_tokens + text_tokens(json.dumps(body, separators=(",", ":")))
        if body["cost"]["total_tokens"] == total:
            break
        body["cost"]["total_tokens"] = total
    if total > budget:
        raise ValueError(f"{action} would cost {total} tokens, over its budget of {budget}")
    return body


print(json.dumps(answer("look", "game left, camera right", 1229, 1600,
                        at="12:00:03.4", look_id=42), indent=1))

External links

Exercise

Pick one tool you have built (or would build) that returns data to a model. Write its contract the way Oriel does: the actions, the most each can return (in pixels and characters), and a budget in tokens per call. Then write the answer shape: what was read, at which moment, any note the model needs to trust it, and the cost it spent.
Hint
Start from the worst case, not the typical one: the longest text field at its cap, the largest image the code may produce. If the worst case does not fit the budget, either the budget or the cap is wrong, and that is the conversation to have before a model ever calls it.

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.