Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

DeepSeek Harness Service Isolation and Scope

DeepSeek Harness Service Isolation and Scope

In this section we will introduce how to make different plugin groups see different instances of the same service.

Behind this are Cordis's service isolation and agent scope mechanisms.


Service isolation: isolate

cordis.yml supports service isolation: the same service can have multiple instances, and different plugin groups see different instances.

The keyword is the isolate configuration, combined with the group plugin to divide plugins into groups.

Example

File path: scratch-plugin/cordis.yml

Define two plugin groups group-a and group-b, each isolating its own shell service

:

group-a

  name

:

'@deepseek-ai/cordis-plugin-group'

  group

:

true

  isolate

:

    shell

:

true              

Let the shell service within the group be instantiated independently

  config

:

    - name

:

'@deepseek-ai/dsh-bash-local'

      config

:

        timeoutMs

:

5000

     

group-a's Bash timeout is 5 seconds

    - name

:

'./src/plugin-a.ts'

:

group-b

  name

:

'@deepseek-ai/cordis-plugin-group'

  group

:

true

  isolate

:

    shell

:

true

  config

:

    - name

:

'@deepseek-ai/dsh-bash-local'

      config

:

        timeoutMs

:

60000

   

group-b's Bash timeout is 60 seconds

    - name

:

'./src/plugin-b.ts'

plugin-a and plugin-b each see the Bash instance in their own group, without affecting each other.

group-a's Bash command timeout is 5 seconds, group-b's is 60 seconds, and neither side knows of the other's existence.

Isolation group and scope schematic diagram


Why is isolation needed

Different tasks may have completely different requirements for the same capability.

For example, a fast interactive task wants Bash to time out quickly, while a long task wants enough time.

Isolation allows the same service to be configured and take effect by group, rather than a one-size-fits-all global approach.


Scope: scope

scope is a registration unit divided by agent.

A contribution (tool, prompt segment, variable, restriction, listener) is either global or belongs to exactly one scope key.

Concept Meaning
scope A registration unit divided by agent; only two levels, using a flat structure
scope key An opaque identifier of a scope; an active agent is the key of its own scope
agent.ctx An agent's scoped context, where registrations have both scope visibility and a lifecycle bound to that scope
shadowing Most-specific-wins name resolution: scoped tools / segments / variables only replace global items with the same name within their own scope
restriction tools.restrict filters the global tool set for a single scope, and multiple restrictions are combined by intersection
lineage Parent-child relationship facts carried as data (parentSession, delegationDepth, etc.) never affect visibility

Scoped registrations are not inherited downward to subagents.

Subtree behavior is expressed through lineage data, not through the scope structure.


Shadowing: most specific wins

Shadowing is a mechanism for customizing persona and tool variants per agent.

A scoped tool only replaces the global tool with the same name within that scope; other agents still see the global version.


Restriction: filtering global tools

Restriction uses tools.restrict to filter the global tool set for a single scope.

Filtered-out global tools neither enter the prompt nor are they allowed to execute, indistinguishable from non-existent tools.

In other words, restriction makes an agent in a scope completely "unable to see" certain global tools, rather than rejecting them at call time.


Summary and self-test

isolate instantiates the same service by group, scope divides registrations by agent, and shadowing and restriction implement same-name replacement and global filtering respectively.

Self-test:

  1. What is the relationship between the Bash instances of group-a and group-b with isolate: { shell: true }?
  2. Are scoped registrations inherited by subagents?
  3. What problems do shadowing and restriction each solve?