Keep workspace files below `'operator'` authority out of the instructions in `RepoContext`, `Skills` and `Memory`, and add `lowest_authority_under`
Why we make these changes
A workspace can mark files as less trusted than the application, for example a cloned repository at authority='none' (#11836, #13213). RepoContext, Skills and Memory read files from the workspace and, until now, put what they found into the instructions, where the model treats it as the application speaking. A planted line in a cloned repository's AGENTS.md or SKILL.md was followed that way.
With this PR, a file below 'operator' never reaches the instructions. Its text reaches the model as data: either as output of a tool the model calls, or as a framed part with a note naming its author. Nothing changes for files at 'operator', the default, which is tested as the control case.
What each capability does now
RepoContext. Each instruction file is read at its own level (Workspace.authority_of(path)).
- The working directory's file below
'operator'is only named in the instructions. The model reads it with its file tools, so its text arrives as tool output. (In the live probe on this PR, a planted line was followed 1/6 on Claude Opus 5.5 and 0/6 on Gemini 4 Argon this way, against 6/6 as a framed block in the instructions.) - An ancestor's file below
'operator'is outside the file tools' reach, so it's sent once as aContextFilePartwith aWorkspaceSource: framed data with a note naming its author. It's sent again only when it changes or a compaction drops it. - A file above the working directory gets the level of the
path_authorityentry that covers it, else the workspace's own level, so a plain workspace loads its ancestors as before. - The sentence about which instruction file takes precedence is left out when any file it covers is below
'operator'.
Skills. Each skill takes the level of its own SKILL.md, in the workspace its library is read from.
- A skill below
'operator'stays out of the deferred-capability catalog andload_capability. The model gets two tools instead:list_skills(names and descriptions) andload_skill(one skill's instructions). Both return tool output. - With
read_files=True,read_skill_filereads the files of a skilllist_skillslists, also as tool output. An'operator'skill still has to be loaded first. - One
path_authority={'skills/vendored': 'none'}entry lowers just those skills, and one agent can mix both routes. - The tools' instruction ("At the start of a task, call
list_skillsā¦") was chosen by a live probe: the right skill was picked 5/5 on six models. A test checks that a lowered skill's description, body and files appear only in tool output, never in instructions, system or user parts, or tool definitions.
Memory. A FileStore snapshot whose MEMORY.md is below 'operator' is attributed to that file (WorkspaceSource) instead of to the agent, because an untrusted repository can plant text the agent never wrote. It's data either way. A store with an 'operator' workspace= of its own keeps the agent attribution, and the docs recommend that setup.
New public API
pydantic_ai.workspaces.lowest_authority_under(workspace, directory) -> Authority: the lowest authority the workspace gives any path at or underdirectory.RepoContextuses it for the precedence sentence, and #11839 uses it to cap aworking_directorydelegate. It replaces the harness's reads of the privateWorkspace._authority_layers().- A keyword-only
label: str | None = NoneonWorkspaceSource.from_workspace(workspace, path, *, label=None). The authority still comes frompath.labelonly sets the path the model sees, soMemorycan nameMEMORY.mdwithout revealing the store's directory.
Follow-ups
- #13774: one
load_capabilityroute that carries each capability's authority. It would replace the Skills-onlylist_skills/load_skilltools and needs #12434 first. - #11839: the third PR of the stack (disk sub-agents), now based on this branch.
Compatibility / release note
Labeled compatibility impact. Release notes:
RepoContext,SkillsandMemoryno longer put text from workspace files below'operator'authority into the instructions.RepoContextnames the working directory's file and sends an ancestor's file as framed data.Skillsoffers such skills throughlist_skills/load_skill.Memoryattributes such a snapshot to its file.- Durable runs record new workspace calls at run start, so a run journaled on an earlier version replays a different sequence. Let in-flight runs finish, or use Temporal worker versioning / a new DBOS app version, before upgrading. The new calls:
RepoContextandCoder: onerealpathper run with nested instruction files (the defaultnested_traversal), plus onerealpathper walk-up instruction file (two withCoder'swalk_up='repo_root');Skills: onerealpathper skill directory and perSKILL.md.
Memoryreplays a run journaled up to v2.73.0 as it was sent then: a snapshot recorded without its source replays as the agent's own memory.RepoContext(autoload_instructions=False)with nested instruction files sends its instruction-file sentence as anon_change='append'block in a<pyai:context>frame, after the agent's literal instructions. The text is the same on every request and every run, so this changes the prompt-cache prefix once on upgrade: expect one cache miss on the first request after upgrading. With the defaultautoload_instructions=True, nothing changes.
Review notes
Memorybelow'operator'is attributed rather than refused (the alternative, asCapabilityCreationdoes since #12558). That keeps it working and honest, and the docs point users to an'operator'workspace=for memory the agent can rely on.RepoContext's walk-up wraps the workspace in anAuthorityWorkspacenaming the walk-up's top directory at'operator'. That's the public-API way to say "covered by an entry, else the workspace's level", since wrapping never raises a level.- Each
list_skills/load_skillcall reads the libraries again throughctx.workspace, so the shared toolset works inside durable activities.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.
š¤ Generated with Claude Code