LAYER 02 · Learn the composition grammar

Scope, realm, and rescope

Project global capabilities into a safe runtime world for each agent

16 min3 source anchorsupstream@47f9438
global defaults + agent-local shadowing
The question this chapter resolves

How can two agents see different tools, personas, and working directories in one process?

Build intuition

Companies in one building share elevators and fire systems but keep separate access, offices, and equipment. A realm bounds service publication; a scope is the access card you currently hold.

MECHANISM

Mechanism

createScope/scopeOf/scopeTarget provide zero-dependency scope primitives. Registries and event dispatch resolve the current agent target at call time.

Agent creation mounts presets and local contributions inside agent.ctx. Local names shadow global defaults and unwind with the agent.

Step 1 of 5

Declare defaults

Deployment-level providers and tools live in the root world.

INVARIANTS

What extensions must preserve

  • Agent-local capabilities must not publish into the root service realm
  • Scope filtering occurs in the authoritative dispatch path
  • Scoped registration identity must be protected
FAILURE MODES

The tempting wrong turns

  • ×Treating cwd as a complete isolation boundary
  • ×Manually filtering a global array by agentId
  • ×Allowing user presets to publish services to the root realm
VERIFY IN SOURCE

Do not trust the conclusion—verify it

These anchors are pinned to official deepseek-harness@47f9438; account for later breaking changes when reading current upstream.

KNOWLEDGE CHECK

Pause for ten seconds before revealing

Why do tool restrictions not filter tools registered inside the agent scope?

Why the next chapter follows

Scope solves runtime isolation; profiles, bundles, and patches solve boot-time product composition.

Learn DeepSeek Harness

An independent learning project. Explanations derive from source; upstream remains authoritative.