Context contract per role

The idea

Each model call carries only its role's layers, in a fixed order. People's messages enter as task state with their ids. Budgets are kept by folding and ranking, never by cutting the prefix.

The problem
Calls carried context they did not need, and state was rebuilt from chat.
Why it matters
Each call sees exactly its role's context, and decisions arrive as facts with their sources.
Where it stands
In production as of

A step-by-step replay of this idea is not published yet. The library adds one when a recorded run shows it.

  • Byte-stable prefix, one session per ticket

    The prefix stays reusable: one prompt and tool catalog per item, stage notes appended to the transcript, the model held within a stage, and cache breakpoints per provider. Claude Code runs as one live process.

  • Tier 0 index with details on demand

    The cached prefix holds an index of about 500 tokens: rules, memory notes and the profile, one line each, pinned at the first turn. Guidance files are quoted rules first within a budget, and whole items load only on demand.

  • Handoff capsules across boundaries

    A versioned capsule keeps the task's intent, criteria, decisions, open concerns, owner and next action across restarts and handoffs. Its tokens are reserved in the budget.

  • ObservationPack and folded results

    A tool result of 10 KiB or more is stored whole. The step keeps the head, the tail and exact diagnostic anchors. Older results fold to one recall line, and the worker can read exact pages back.

  • State in the repository (.agents/)

    A repository's .agents/ folder holds rules, memory notes, task checks and summaries. It is shared through git and read back in.

  • Approved examples as style references

    Worker outputs from merged or approved pull requests become examples. Later act and chat turns cite them as style references, never as instructions.

Turn the numbers into shipped work.

Crewshal runs these choices for you: a persistent AI worker with memory and rules, on your Claude and Codex subscriptions.