Context for one task: how to avoid sending the whole platform to a model
Two packs for one change show how to select specific sources, preserve their revisions, and identify required evidence that was left out of the context.
The task fits on one line: add the number of remaining seats to a public workshop card. Nearby are a product overview, launch history, booking rules, the response contract, and test examples. Sending everything seems easier than deciding which passages are actually needed. Once a size limit is applied, however, some text will disappear anyway. The question is whether that choice will be explicit.
This change needs a small set of answers: which fields the card already has, how seats are counted, which data may be shown, and which boundary case must be preserved. A system overview can help with orientation, but it cannot replace any of those answers.
Consider an independent Python exercise. It builds two context packs for the same synthetic task and compares their contents. No model is called: the results are assembled data, a selection log, and visible omissions. The exercise does not measure the quality of a future AI response.
First identify what a decision would be missing
The fictional card already contains slug and title. We need to add a non-negative integer remaining_seats, preserve the existing fields, and keep participant details private. The counting rule is simple: subtract confirmed bookings from capacity and floor the result at zero. Cancelled bookings do not count. Temporary reservations are outside this example's conditions.
Before selecting sources, we prepare a map of the evidence the change requires. A person writes this map for the specific change; it is not inferred from search results.
| Question | Required passage | Accepted revision |
|---|---|---|
| What does the card return? | Response field contract | r4 |
| Which bookings reduce availability? | Counting rule | r7 |
| What may be returned to a reader? | Public data boundary | r3 |
| What happens at the boundary? | Capacity and overbooking examples | r2 |
The map makes an omission visible. If the pack lacks the counting rule, the word “booking” in an overview does not answer that question. The map itself can still be incomplete: a real product might have additional booking states. The automated check tracks the evidence we named; it does not prove that we understand every part of the task.
A source means a specific passage at a specific revision
The exercise catalogue contains eight handwritten passages. Alongside the four required ones are an overview, a historical note, a record marked as restricted, and an unrelated newsletter schedule. None contains real personal data or a private implementation.
Each passage has a document and section reference, revision, text, and a local flag indicating whether it may be shared. The task separately lists allowed references and expected revisions. The r7 match is checked against that independent list; a passage at r6 is not silently substituted as “close enough.”
This provides traceability within the teaching dataset. The sharing flag does not implement access control, and a revision label does not authenticate a document's origin. When connecting a real source, we must separately establish who permitted its use and which exact bytes belong to the accepted version.
The local log stores a digest of the selected text. Python provides the hashlib interface for this. If text changes under the same revision label, comparing records reveals different bytes. However, someone who can change the entire dataset can also change the log. A digest does not replace independent source verification.
Bound the whole pack, not just passage lengths
Both variants have the same limit: 1500 bytes. It covers the complete serialized payload, task text, field names, revisions, and selected passages. The selection log is stored locally as a separate artifact and is outside that limit. This is an explicit boundary around one artifact; it is not a limit for the complete future API request.
Bytes are not model tokens either. The exercise has no tokenizer, so it does not calculate a token count. Integration with a specific model would need to account for that model's counting method and the rest of the request's messages.
Serialization uses UTF-8, a defined key order, and compact separators. The corresponding options are described in the Python json documentation. After adding each whole passage, the packer checks the size of the complete proposed pack:
proposed = {**payload, "sources": payload["sources"] + [excerpt]}
proposed_size = len(encode(proposed))
if proposed_size > budget:
record.update(reason="budget", proposed_bytes=proposed_size)
An oversized passage is omitted in full. The algorithm does not cut off trailing words that might contain a negation or an exception; it moves on to the next candidate. This is greedy selection in a specified order. It does not search for a globally optimal combination of documents or assess their semantic usefulness.
Two orders leave different gaps
The first order starts with the overview, contract, and launch history. The second contains the four passages from the evidence map. Both use the same task text, catalogue, and budget. The decision about source composition and order is what changes.
| Local assembly result | Broad order | Selection for the task |
|---|---|---|
| Complete payload size | 1373 bytes | 995 bytes |
| Selected passages | 4 | 4 |
| Response contract | Present | Present |
| Counting rule | Present | Present |
| Public data boundary | Did not fit | Present |
| Boundary example | Did not fit | Present |
Four passages in each pack do not make the packs equally suitable. In the broad variant, the overview and history consume part of the budget. In the second, each selected passage answers one of the questions defined beforehand. We do not add the rest of the catalogue simply because space remains.
The composition check marks the first pack as insufficient for the declared task. The second contains all the evidence listed in our map. This allows the next step to stop until a specific gap is addressed. The sufficiency flag applies only to that map; it is not permission to change code or publish a response.
Every omission needs a reason
The log distinguishes several situations. A passage may exceed the budget, lie outside the task, have a different revision, be missing, or be marked as unavailable for sharing. It also shows catalogue entries that were never candidates in the selected order.
These reasons imply different next actions. A budget shortage can be addressed by removing an optional overview or separately reconsidering the limit. A different revision requires opening the current source. A sharing restriction requires permitted alternative evidence, not a larger limit. If a required passage is absent, the result remains incomplete.
The omission list can itself contain sensitive names. All identifiers in the exercise are fictional; a real system needs a separate access policy for the log. Leaving a document's text out of the payload does not automatically make its name safe to distribute.
Check the mechanism without promising a correct answer
The local run on Python 3.12.14 executed 40 scenarios, all with the expected response. They include a pack at the exact limit, one byte too little, multibyte Ukrainian text, a different revision, a missing source, duplicates, repeated assembly, and refusal to overwrite an existing report. The number of provider calls is 0.
Two control cases deliberately show the mechanism's boundary. Replacing the counting rule with false text while retaining the revision can still satisfy the evidence map. Inserting an unrelated instruction into an allowed passage causes the packer to preserve it as text. The packer does not execute it, but that does not establish that a future model will ignore it.
OWASP's prompt injection guidance discusses the mixing of instructions and data. Separating sources from the task helps structure a request, but it does not provide complete protection by itself. A real integration needs separate tool access rules, output checks, and defined action boundaries.
A context pack should be reviewed against concrete questions: does the task match, which revisions were selected, what was omitted, and which required evidence is missing? Such a record gives the next session a clear basis for work. The model's response and the eventual change still need their own verification.