Introduction

In the DeepSeek Harness ecosystem, agents often use free-form text as their memory. Recorded content may become contradictory over time or drift from the original definition. More importantly, textual memory cannot automatically infer implicit relationships, leading to fragmented knowledge.

The dsh-ontology plugin provides agents with a structured knowledge framework. It defines domain knowledge as a typed ontology (TBox + ABox), enforcing agents to comply with schema constraints when declaring classes and relations. In this way, assertions are validated before storage, and inferred implicit facts are generated on-the-fly at query time instead of being stored redundantly.

Plugin Positioning

This is a typed, inference-capable ontology plugin for DeepSeek Harness. It consists of two parts: TBox (concept definitions and relation types) and ABox (instances and factual assertions). Agents can declare domain knowledge, assert facts, and run queries under schema constraints.

Core Features

  • Typing and Reasoning: Supports schema constraint validation, as well as reasoning over transitive, symmetric, and inverseOf relationships.
  • Dependency-Aware Retraction: When removing facts, the plugin automatically handles dependencies to prevent orphaned data from remaining.
  • Multi-Mode Querying: Supports multiple query modes, including schema, stats, entities, facts, neighbors, and path.

Installation and Enablement

Use the official commands to add the plugin to a specified Profile:

dsh plugin --profile <name> add dsh-ontology
dsh --profile <name>

Configuration and Usage

After installation, you can override default configuration options through the Profile’s cordis.patch.yml, such as store name, strict mode switch, and reasoning switch.

1. Define Schema (TBox)

Use ontology_define to declare classes and typed relations.

// ontology_define
{
  "classes": [
    { "id": "Service", "subClassOf": ["Component"] },
    { "id": "Component", "comment": "A deployable unit of the system" },
    { "id": "Person" }
  ],
  "relations": [
    { "id": "depends_on", "domain": ["Component"], "range": ["Component"], "characteristics": ["transitive"] },
    { "id": "owns", "domain": ["Person"], "range": ["Component"], "inverseOf": "owned_by" },
    { "id": "owned_by", "domain": ["Component"], "range": ["Person"] },
    { "id": "version", "domain": ["Component"], "rangeKind": "literal" }
  ]
}

2. Assert Facts (ABox)

Use ontology_assert to record entities and facts. In this step, the system validates whether assertions conform to the defined schema.

// ontology_assert
{
  "entities": [
    { "id": "api", "classes": ["Service"] },
    { "id": "auth", "classes": ["Service"] },
    { "id": "pg", "classes": ["Component"] },
    { "id": "ada", "classes": ["Person"] }
  ],
  "facts": [
    { "subject": "api", "predicate": "depends_on", "object": "auth" },
    { "subject": "auth", "predicate": "depends_on", "object": "pg" },
    { "subject": "ada", "predicate": "owns", "object": "api", "source": "CODEOWNERS" },
    { "subject": "api", "predicate": "version", "object": "2.1.0" }
  ]
}

3. Query and Reasoning

Use ontology_query to perform lookups. Because depends_on is defined as transitive, querying dependencies of api automatically includes pg.

// ontology_query
{ "mode": "facts", "subject": "api", "predicate": "depends_on", "includeInferred": true }

The result includes the inferred fact:

api depends_on auth
api depends_on pg (inferred: transitive)

4. Safe Retraction

Use ontology_retract to remove facts. If an entity is removed, all inferred facts that depend on that entity are also removed.

Notes

  • Build Permissions: If installing via github:, pnpm ≥10 is required. You must add allowBuilds: { dsh-ontology: true } to the Profile’s pnpm-workspace.yaml.
  • Naming Convention: Store name must match /^[a-z][a-z0-9_]*$/.
  • Isolated Execution: Running isolated graphs requires a separate store name.
  • Literal Restrictions: Relations whose values are literals cannot be marked as symmetric, transitive, or inverseOf; otherwise the definition is rejected.

Summary

dsh-ontology transforms agent memory from a “bag of text” into a controlled knowledge graph. Through strict schema constraints and automatic reasoning, it ensures the reliability and consistency of domain knowledge. For agent development scenarios that require long-term memory and handling complex dependency relationships, it is a practical tool.

More Information: GitHub Repository | Community Catalog