User guide: contents

Context of a run

An issue run is given a context bundle: a record of what the run was given to read, with the files themselves. It is made once, from the commit the workspace has, just before the run's first agent step (the first step that is not a shell step or an approval). It holds the issue text, its comments, the repository's AGENTS.md and CLAUDE.md, the ownership file, the files the task names, the API schema files and the README.

The planner and coder prompts of the built-in issue flows get a list of the bundle's entries instead of the pasted issue text. Each entry gives the file to read, and only the entries the step's role may use are listed (the planner, coder, reviewer or tester role, by the step's skill_role, default coder). A source that is stale, not there or not for the role is listed as left out, with its reason, and the agent is told not to look for it elsewhere. Claude can read the context folder but cannot write to it; the workspace stays writable as before. A run with no bundle keeps the issue text in its prompt. A comment the Foundry wrote is marked in the list as by: Foundry, and in the issue text as (Foundry) in its header. Any other comment is not marked, so a comment that copies the Foundry's header does not get the mark.

Plans cite their sources. When the run has a bundle, the planner writes its requirements, constraints and acceptance criteria with a citation at the end of each item, such as [source: s-0123456789abcdef], naming the entries it rests on. Only entries the planner was given can be cited. The plan also has a ## Missing context section that lists the entries the plan needed but did not get, with the reason, or says "none". A READY plan in which some of these three sections cite no entry gets a policy warning (context.uncited): it shows in the run log and in Policy decisions in Details › Evidence of the change's page. The plan step does not fail. A run with no bundle gets no citations and no warning.

Asked and assumed. The plan lists its points in two kinds of line. ASKED: is a point taken from the issue, its comments or the task. ASSUMED: is a choice the planner made itself that the issue does not settle, such as a file location, a default value or who may see something. Read the ASSUMED: lines first: a wrong guess is easier to catch before the work is built. The run record keeps them as planPoints, a list of { kind: "asked" | "assumed", text }. A plan without these lines, and an older run, has no list.

Your request. When a run has these points, its Progress tab shows a Your request box after the acceptance criteria. You asked and Assumed are marked with a word and an icon, and an assumption has a dashed edge, so the two are told apart without colour. The box is not shown when there are no points. Change this on an assumption opens a box for the correction in plain words; Send correction sends it as a reject of the plan on the issue, with the text Assumed: <assumption> — Correction: <your words>, so the planner makes the plan again with it. Change this is offered only while the plan waits for a decision and you may reject it (the same rule as Approve and Reject). Otherwise the box is read-only and says why. In Simple, the same box is on the check card of a plan that waits for a decision, under What you need to do on the project page; it sends the correction the same way as Something is not right.

  • The settings. The context: section of config.yaml has seven keys, all optional:

    • max_sources (default 200): the most files in the bundle.
    • max_source_bytes (262144): the most bytes of one file.
    • max_total_bytes (2097152): the most bytes of all files. It may not be below max_source_bytes.
    • classification (internal): the privacy the files are given.
    • max_classification (restricted): the most private file that may be used. A more private file is left out.
    • consumers (planner, coder, reviewer and tester): the roles that may be given the bundle. A list with at least one role, each at most once.
    • task_max_age_seconds (null): how long the issue text stays fresh, in seconds. null means it never goes stale. The issue's time is the latest fetch of the ticket in this run, so a resumed run is judged by its newest fetch.

    A wrong value is reported when the configuration is checked, at context.<key>, and the message never shows the value.

  • 30 seconds. The bundle must be finished 30 seconds after the step starts. A bundle not done in time is not written: the run goes on, and the log gives CONTEXT_FAILED timeout.

  • The log. One line per run. A success reads, for example, · context: 12 sources, 3 left out, commit 1a2b3c4d5e6f, with , 2 comments skipped added when some comments could not be read. A failure reads ! context: CONTEXT_FAILED <code>. Neither line shows a path or a value.

  • The codes.

    • marker-failed: the attempt marker could not be written.
    • repository-no-commit: the workspace has no commit yet. repository-… otherwise means the repository could not be read in time or is not usable.
    • issue-unreadable, comments-unreadable: the issue files that pull_ticket saves are missing or not valid.
    • select-invalid: the context: settings cannot be used.
    • bundle-invalid: the bundle made did not pass its own check.
    • timeout: not finished within 30 seconds.
    • lock-failed: the files could not be made read-only. The bundle is removed.
    • store-…: the files could not be written. The files written so far are removed.
    • internal: anything else.

    A failure never stops the run.

  • Evidence and policy. The run's evidence records the bundle: a context.bundled event with the bundle's hash, its limits, its source and byte counts and the number left out per reason, or the failure code. Policy packs are asked at the boundary context.select after a bundle is written. The answer is only recorded; the run goes on either way.

  • Context sources on the change's page. The Evidence section of the Details tab has a Context sources section. It lists the sources the run was given, with the reason each was picked, the time it was read and whether it is Fresh or Stale. Below them it lists the sources that were left out, each with its status and What to do. A run from before the bundle existed says This run has no context bundle.

    • Statuses. Not found: the file is not in the repository at the run's commit. Too old: the copy is past its age limit. More than one fits: the name matches several sources. Over the context limits: it did not fit max_sources, max_source_bytes or max_total_bytes. Too private for this run: it is more private than max_classification allows. Made by a program: the repository marks it as generated. Not a text file: it is a link, a submodule or a binary file.
    • Who sees what. An administrator sees the exact address (uri) and id of every entry, and the wording for the limits and the classification tells them which setting to change. A user sees a plain label, for example "Repository file docs/API.md", "Issue #12" or "Comment 34 on issue #12", and no address, id or owners. For a confidential or restricted source a user sees only the kind and the classification, for example "Restricted repository file". Machine folders are never shown.
    • Export. Export context saves what the page shows as context-<run id>.json. It is the answer of GET /api/runs/:id/context, so the export has the same visibility as the page. It has the hashes and the times, but never the text of a source.
  • Read-only files. context.json is read-only, and so is every file under context/. Folders are read-only too. On macOS the OS sandbox of a step also denies writes to these paths.

  • One attempt. The file context.attempt is written before the bundle is tried, and it stays. A run gets one attempt: a run that has an attempt, a bundle or a context/ folder gets no other, also after a resume. A run that already took an agent step gets no bundle.

  • Which runs. Only runs of flows that save the issue files (the built-in issue flows). A custom flow gets no bundle and no line in the log.

  • Removal. scf clean --purge removes the bundle with its run.

Improve this page on GitHub