DEV Community

ellytan
ellytan

Posted on Edited on AI-assisted

Beyond Memory: How Ontology Helps Coding Agents Understand a Project Better Over Time

By TencentDB Team (腾讯云数据库)

English translation of our team's Chinese article, prepared with AI assistance.

How can an agent gradually become familiar with a project? A general-purpose model brings coding and reasoning abilities, but it must learn a particular project's concepts, conventions, and history from the team's materials and actual work. Once it has that information, it must also determine when it applies and how it should affect the task at hand.

This raises two distinct questions: how to represent project knowledge so the model understands what we are discussing, and how to use execution feedback to benefit future tasks. Ontology and recursive self-improvement (RSI) offer approaches to these two questions, while memory stores knowledge and makes it reusable.

We start with these concepts, examine research connecting them, and then describe our internal development loop. Our practical goal is to reduce the time agents spend rediscovering a project and the mistakes they repeat after the team has already worked out the answer.

Article overview: ontology defines business meaning; memory retains team experience; RSI improves capabilities and methods. Our practice connects engineering facts, project semantics, and experience across repositories, with preliminary localization success rising from 58% to 65%.

Overview. The original diagram uses Chinese labels. It connects the basic concepts, related research, our development loop and three-layer graph, preliminary evaluation, and the goal of carrying verifiable, correctable understanding into the next task. End-to-end benefits and sustained improvement remain to be established.

1. What does ontology mean in the AI era?

1.1 From word meanings to a shared model of a domain

Here, ontology refers to the knowledge-engineering concept; we will leave the philosophical discussion of existence aside. A useful starting point is this: an ontology explicitly represents a domain's concepts, their relationships, and the conditions under which they hold, in a model that can be shared.

“Shared” matters. One person's understanding of an order being complete does not mean the warehouse system, finance system, and customer service team use the same definition. Likewise, a model's understanding of the word “complete” does not tell it whether a company considers payment, shipment, or delivery confirmation to be the completion criterion. An ontology makes these domain conventions explicit.

Consider a simplified order system. “Order” and “shipment” are concepts or types; a particular order is an individual object; “an order has a shipment” is a relationship; amount, currency, and creation time are attributes. If the business supports split shipments, an order can have several shipments. If an order is complete only after all valid shipments have been received, that condition must also be explicit.

“One shipment has been received” and “the entire order is complete” are therefore not interchangeable. The distinction comes from objects and relationships, rather than the similarity of two sentences. If split-shipment rules change across business versions, their scope must be recorded too.

More formally, an ontology gives concepts and relationships explicit semantics. There should be a consistent interpretation of which objects belong to a class, which objects a relationship can connect, and which conditions justify a conclusion. W3C's OWL 2 provides ways to express classes, properties, individuals, and logical axioms. Ontology predates large language models.

Engineering teams do not have to begin with a fully formal language. Versioned concept definitions, relationship types, data mappings, and rule files can gradually serve these purposes. What matters is that meanings can be checked, instead of requiring the model to infer them afresh from scattered materials.

We should also distinguish expressing a rule from establishing that actual data satisfies it. An ontology can express the relationship between orders and shipments, but determining whether a particular order is complete still requires querying and checking the data. SHACL addresses constraint validation for graph data; ordinary programs and tests can also perform business checks. Writing down a rule does not guarantee that reality follows it.

1.2 How does it differ from schemas, knowledge graphs, and RAG?

These concepts often appear together, but emphasize different things. A database schema primarily describes data organization. A knowledge graph describes entities and relationships. Retrieval-augmented generation (RAG) supplies retrieved material to a model. An ontology emphasizes shared meanings for objects and relationships. They can be combined, and their roles can overlap.

An order table might contain a status field. Its existence does not tell us whether it describes an order or a shipment, which values are intermediate states, or when it establishes business completion. If that knowledge lives only in an engineer's memory, an agent still has more searching to do after reading the schema.

Approach or asset What it primarily provides Questions that remain when used alone
Database or API schema Fields, types, data structures, and some constraints What fields mean in the business and how they map across systems
CodeGraph Symbols, calls, dependencies, and code locations What business responsibilities a call chain serves and which conventions must be preserved
Knowledge graph Entities and instances of relationships Whether relationships have explicit meanings, scope, and supporting evidence
Documentation and RAG Material relevant to the current question Whether passages concern the same object and apply to the current situation
Ontology Shared concepts, relationship semantics, and associated axioms or constraints Whether current facts satisfy the definitions and actions produce the expected outcomes

This table does not imply that RAG can only search text or that schemas cannot express semantics. A good RAG system can use graphs, rules, and structured filters. The distinction is that improving retrieval and completing domain meanings are separate tasks. Finding a policy still leaves the question of whether it applies to the current vehicle model, model year, region, and date.

Ontologies and knowledge graphs are not mutually exclusive. A graph can organize facts according to an ontology, and an ontology can itself be represented as a graph. But if every edge is labeled “related,” the model still cannot tell whether the relationship means implementation, dependency, or violation of a constraint. Connecting more nodes and expressing relationships more accurately are different goals.

The missing capability is being able to determine, after finding a piece of knowledge, which object it concerns, under what conditions it holds, and which inference it supports. Whether it is stored in a graph database, relational tables, or files is a subsequent implementation choice.

1.3 Why Palantir and forward-deployed engineers encounter this problem

Palantir's Ontology system connects data, logic, action, and security. It organizes queryable data while linking business objects to logic, operations, and permissions. Models and applications understand the system through business objects and affect it through controlled actions.

For example, migrating an instance involves the relationship between instances and nodes, destination-region restrictions, migration states, available actions, and operating permissions. Knowing which table represents an instance is insufficient. The object model must connect to the actual workflow, and results must be checked after execution. Actions and permissions are extensions in such product systems; they should not be treated as part of every classical definition of ontology.

Palantir's modeling guidance emphasizes starting with the real-world domain and then mapping source data. This is useful for software development too. The same business object can span several systems, and one table can mix multiple business concepts. Turning tables into graph nodes does not automatically supply the missing meanings.

This helps explain why a forward-deployed engineer (FDE) would care about ontology. Engineers working closely with a specific business must connect user goals, existing systems, and delivery criteria. When a user says “the process succeeded,” the engineer still has to establish which object and stage succeeded: was the request accepted, or has the business outcome taken effect?

In our view, the closer an agent gets to real operations, the harder it is to skip this work. Inconsistent meanings propagate into tool parameters, implementations, and acceptance assertions. An ontology offers a way to turn business clarification into a shared model, rather than explaining it again in every feature's prompt.

The AI era has not changed ontology's basic meaning. What has changed is its more direct role in agent retrieval, judgment, and action, and the need to maintain it as business requirements and execution feedback change. That leads to another question: can this understanding accumulate across tasks, and can the system improve how it acquires that understanding?

2. Understanding RSI through loops and memory

2.1 Repeating tasks does not mean the system has learned

First, a word about agents and loops. An agent uses a model to make decisions, calls tools to act, and continues based on environmental feedback. A loop is this cycle of acting, observing, and adjusting. In coding, writing code, running tests, reading failures, modifying the code, and testing again already form an execution loop.

That loop can improve the current task's outcome without changing the next one. If a new session starts from the same information, it may search the same path again and misunderstand the same business convention. Completing a task and learning across tasks require separate designs.

Memory preserves information for use across rounds. It can retain events, confirmed knowledge, or methods for handling tasks. Even with unchanged model weights, an agent system can perform better when it has more appropriate knowledge and tools.

Reflexion provides an example using linguistic feedback: an agent reflects on task feedback and stores those reflections in episodic memory to guide later attempts. Agent Workflow Memory focuses on reusable workflows, deriving procedures from past experience and selectively supplying them to subsequent tasks. The former shows how feedback can become memory; the latter shows that memory can also encode how to do something.

But storing information is not the same as learning, and reuse does not guarantee improvement. Reliably retrieving a mistaken lesson can make mistakes recur more reliably. When we describe memory as a method and fuel for self-improvement, we must add: experience has to change subsequent behavior, and later outcomes must establish whether it helped.

Feedback should retain more than “success” or “failure.” Similar failures can arise from code defects, environmental problems, faulty observers, or confused business concepts. Applying the same reflection template to all of them easily produces broad advice that cannot guide action. Useful feedback retains the circumstances, evidence behind the judgment, and explanations that were ruled out.

2.2 What makes recursive self-improvement recursive?

RSI stands for recursive self-improvement. Self-improvement means a system changes parts of itself to improve subsequent performance. Recursion goes further: the process that produces improvements can itself become an object of improvement. Useful questions are: what changed, who changed it using which feedback, and how was the change validated?

We distinguish three levels by what is modified. This is an engineering perspective for analysis, rather than a standard classification shared by all papers.

Level Where change occurs Development example
Iteration within execution The current task's plan or output A test fails, so the code for this requirement is revised
Self-improvement across tasks Persistent knowledge, tools, or working methods A verified compatibility lesson is saved for the next task
Improvement of the improvement process Methods for generating, selecting, and validating improvements Later outcomes lead to changes in lesson extraction or skill optimization

The Darwin Gödel Machine studies iterative changes to an agent's own code. It maintains candidate agents and selects changes through coding evaluations. What changes is the problem-solving system's tools and mechanisms, rather than only the code for one problem. That differs substantially from patching code whenever a test fails.

The preprint Skill∞ makes the recursive relationship more explicit. Task skills retain methods for solving tasks, while a meta-skill describes how to optimize those skills. A meta-agent diagnoses execution traces, proposes candidates, requests independent review, and allocates a search budget. The same optimization process can then operate on the meta-skill itself.

One version might improve how to localize a bug; another might improve how to analyze failed localization attempts and generate better localization methods. The latter must be evaluated by whether it produces better task skills within a given budget. Skill∞ keeps scoring outside the scope of self-improvement and requires independent candidate review. Improving a method is distinct from lowering the scoring standard.

These studies give RSI concrete experimental objects, but operate under bounded tasks, budgets, and validation conditions. In enterprise development, we can start with external memory, tools, and workflows without first changing foundation-model weights. A positive experiment also does not establish that a system can keep improving indefinitely.

The roles are now clearer: ontology helps a system represent and use domain knowledge; RSI concerns how a system improves itself through feedback. Neither requires the other. When misunderstanding concepts is a major bottleneck, however, ontology becomes a useful object of improvement.

3. Bringing ontology and RSI together

3.1 EvoOntology: evolving an ontology through agent usage feedback

A directly relevant preprint is EvoOntology: A Self-Evolving Ontology Layer for Data Agents. It examines data analysis and text-to-SQL: turning natural-language questions into SQL queries. Agents working with databases or files repeatedly investigate field meanings, table relationships, and filtering conditions. Even after resolving them in one task, they may rediscover them in later tasks.

The paper divides an evolvable ontology system into Content, Schema, and Tool. Content retains domain concepts, mappings to data fields, usage constraints, and evidence. Schema defines how those objects and relationships are represented. Tool determines how an agent finds and expands the information. These components differ from our three-layer project graph described later; their names should not be mapped directly onto our layers.

It provides two forms of access: browse finds semantically relevant objects, and resolve retrieves the required objects and associated records. Sessions begin with only a short description; agents query specific knowledge as needed. The ontology is therefore both maintainable knowledge and an interface agents actually use.

A card-query example in the appendix makes this concrete. The task is to find cards banned in a particular game format. The initial ontology knows the relationship between cards and legality records, and that status resides in legalities.status, but does not explicitly say that status is relative to a format. The agent can find the field, yet still has to establish how to use it.

Evolution identifies missing semantic content and adds status meanings, corresponding fields, observational evidence, and constraints. Finding banned cards for the target format requires both legalities.status = 'Banned' and legalities.format = target_format. Checking only “banned” loses the scope. This change adds content without changing the query tool or the entire schema.

Crucially, the paper does not respond to every failure by adding another prompt paragraph. It analyzes traces to determine whether the limitation comes from missing content, unsuitable tool exposure, or a schema unable to represent the required knowledge. Each candidate makes a local change at one of these levels. Candidate and baseline are compared using the same model, validation set, and interaction budget. A change is retained only if improvement reaches the prescribed threshold; unsuccessful changes are recorded rather than deployed directly.

The design also separates material used to construct and select candidates from final test tasks. The ontology is frozen before final testing. A system cannot inspect test answers, add semantics, and then report performance on those same tasks. Tools still execute and validate complete queries; the ontology supplies grounded interpretations and usage conditions.

The central idea is that an ontology can help agents understand tasks and can itself be revised in response to their actual use. Revising an ontology remains distinct from recursively improving its revision mechanism. EvoOntology directly studies the former; Skill∞ provides a reference for understanding the latter. Results from data tasks require new experiments before they become conclusions about development loops.

3.2 Our approach: give experience a home and feedback a specific target

Together, these studies suggest an increasingly concrete path. Reflexion examines retaining experience from feedback. Agent Workflow Memory examines reusable methods. EvoOntology examines how semantic knowledge and access to it can evolve. Skill∞ makes the optimization process itself modifiable.

For us, the key lesson is to avoid treating every failure as evidence that the model is not smart enough or memory is not large enough. A localization failure can have different causes: a code relationship was missed, business meaning was misunderstood, a past lesson's conditions did not match, or a known constraint never became an actual check.

Ontology can make attribution more specific. A failure can be associated with a business concept, a cross-repository mapping, a state condition, or an incorrect inference, as well as a session. That gives the next improvement a concrete target without rewriting all memory.

Confusing request acceptance with business completion calls for adding or separating concepts. If concepts are accurate but search returns only similar old cases, indexing or applicability filtering needs work. If retrieval and interpretation are correct but data-plane checks are still omitted, the workflow and validation tools need examination. Repeating the same reminder cannot solve all three problems.

We want the loop to provide actions and actual outcomes, memory to retain experience and provenance, and ontology to organize concepts and applicability conditions. Subsequent tasks then establish whether that knowledge changed behavior. Improving extraction, retrieval, and usage strategies based on those results takes the work further, into improving the learning mechanism.

There is a cost that is easy to overlook. Semantic organization increases extraction and maintenance work, and graph relationships can amplify incorrect experience. Combining ontology with RSI requires both the ability to connect knowledge and the ability to correct it. The system must be able to narrow a lesson's scope, separate incorrectly merged concepts, or retract unsupported conclusions, rather than merely adding more content.

3.3 What does an experienced engineer see when reading code?

To decide which knowledge is worth extracting, we start with a simple question: beyond knowing which function calls which, what does an engineer familiar with the project know?

They may not remember a function's exact line number, but know which business process it belongs to, who advances its state, and which consumer still depends on an old protocol. A special branch recalls why it was kept. An anomaly suggests which observation will distinguish an environmental issue from a real defect. The engineer also knows which conditions must remain true as workflows change: the business invariants discussed below.

Judgment while reading code Project knowledge to retain
Why does this code exist? Functional responsibility, business goals, design decisions, and rejected alternatives
Does a parameter's meaning change across this boundary? Field mappings, units, defaults, null or empty-value semantics, and compatibility
Who advances the state, and when is it finished? Lifecycle, state scope, responsible actor, and evidence of completion
Which condition must never be broken? Contract-backed invariants, preconditions, and counterexamples
Who is affected if this changes? Cross-repository consumers, dependency paths, version scope, and relevant tests
Why did this fail before? Trigger conditions, evidence for the root cause, repair trade-offs, and applicability limits
How can the current hypothesis be disproved? Diagnostic branches, discriminating observations, regression cases, and unresolved questions

Knowing what remains unknown matters too. An experienced engineer distinguishes the current implementation, confirmed requirements, and personal hypotheses. When they conflict, the engineer returns to the design or asks the business owner. Extracted project experience should retain those distinctions rather than treating every confident explanation as fact.

We do not need to reproduce a person's entire thought process. We can start by externalizing clues that repeatedly affect localization, change scope, and verification. Ontology provides shared concepts, historical cases provide experience, skills provide methods, and tests and runtime results provide validation. The next step is to put those roles into our actual workflow.

4. Our practice: three layers of project knowledge in the development loop

4.1 From completed design to pre-release testing

Our current practice assigns agents the work from implementation through pre-release testing after requirements and design are complete. People establish goals, design, and necessary business trade-offs. The agent understands the requirements, implements changes, verifies them, and diagnoses and repairs failures until the agreed acceptance results are obtained.

A completed design does not eliminate ambiguity. At the beginning of a loop, the agent must translate the design into observable acceptance criteria, specifying objects, scope, inputs, expected states, and exclusions. Business conflicts still require clarification rather than guesses. This scope does not automatically include production release or other unauthorized actions.

Development loop: completed requirements and design lead to understanding and planning, implementation and persistent tests, integration preparation and candidate deployment, and unit, functional, and regression testing. Acceptance produces evidence and cleanup. Failures or unknown outcomes trigger diagnosis and return to the relevant stage.

Figure 1. The development loop proceeds from completed design to pre-release acceptance. Failures return to the relevant stage according to their cause. Based on our current internal workflow; original Chinese labels are retained.

English reading guide: requirements and design → understanding and planning → implementation and persistent tests, including local compilation and static checks → integration-environment preparation and candidate deployment, checking artifacts and runtime identity → native unit tests, functional tests, regressions, and necessary data-plane checks → acceptance decision. Success leads to evidence collection and cleanup of owned resources. Failure or an unknown result leads to diagnosis of the original task: clarify business semantics, fix implementation or tests, or restore the environment or observation as appropriate.

In our current cloud-database development path, local work primarily covers compilation and static checks. Native unit tests, functional tests, and affected regressions run in the integration environment. Where necessary, we also verify access behavior on the actual data plane. An API returning success, an asynchronous task finishing, a process becoming ready, and a client being able to use the service each require evidence matching that meaning. Our current path mainly covers backend and data-plane work; it cannot be generalized to automated acceptance of all frontends or product types.

Figure 1 does not require restarting the entire loop after every failure. A report-only change with unchanged inputs may not need redeployment. Changing a test observer, however, requires revalidating the affected judgments. If the outcome of a write request is unknown, first restore observation of the original task to avoid repeating an operation that may already have occurred.

There is another important division of labor. The agent handles semantic understanding, planning, implementation, and exceptional judgments. Deterministic tools advance routine steps whose behavior is already decided. Building, deploying, waiting, and collecting receipts do not need a fresh model decision at every step. Tool success cannot substitute for business acceptance. The loop must deliver acceptance evidence tied to the actual version, rather than just a model saying “done.”

Execution also produces material worth learning from: a misunderstood concept, a compatibility issue exposed by a test, or a clarification that changed implementation direction. Team memory makes this information available to the next loop rather than losing it when the session ends.

In analyzing actual bottlenecks, we found that much confusion and rework involved business concepts. Models could understand local code but did not accurately understand the project's objects, states, or field meanings. This is a practical observation; we have not quantified its share of all failures. It nevertheless motivated adding semantic relationships to existing memory, rather than simply saving more raw conversations.

4.2 Four memory assets and a graph with three mutually indexed layers

Our team memory already contains four kinds of assets. Chat Memory preserves context, clarifications, and decisions from conversations. Wiki organizes business and architectural knowledge. CodeGraph provides code structure and dependencies. Skill stores reusable methods. Each serves a purpose, and original sources should be retained.

Alongside these assets, we have built a three-layer relationship graph for individual repositories and across repositories. The four asset types and three layers describe different dimensions: the former concern material formats and uses; the latter concern how knowledge is connected and accessed. They are neither seven parallel asset categories nor a strict one-to-one mapping.

The first layer is engineering facts. Built mainly through engineering analysis, it establishes relationships among functions, types, fields, APIs, and their users. It resembles CodeGraph but also includes cross-repository relationships, and is largely static. It helps agents locate definitions, identify users, and determine which repositories a feature may span.

Cross-repository relationships must be checked against contracts such as APIs, messages, and schemas to match producers with consumers. Matching symbol names alone is insufficient. Static graphs may also fail to establish actual paths for reflection or configuration-based routing; runtime information is needed. A possible connection in code remains distinct from the path taken in a particular execution.

The second layer is project semantics. Combining engineering analysis with LLMs, it extracts functional responsibilities, business concepts, relationships among definitions, field meanings, cross-repository mappings, and associated constraints. It supports both local and cross-repository knowledge. This layer is more dynamic, changing as new material arrives and understanding is corrected.

The first layer can show that a field travels from repository A to repository B. The second explains what it means at either end, whether units change, whether defaults match, and which versions require compatibility. Semantic explanations therefore need verifiable engineering anchors. A fluent relationship proposed by an LLM cannot, by itself, be promoted to a project fact.

The third layer is errors and experience, which we call bug_fixed. It turns historical bugs into lessons linked to relevant nodes and relationships in the first two layers, exposing them through progressive disclosure. Code can lead to relevant experience, and experience can lead back to code and business conventions.

We distinguish a past event from a reusable lesson. An event records version, symptoms, conditions, causal judgments, and repair. A lesson distills the risk it reveals and the scope in which it applies. One event can support several lessons, and several events can support a constraint. The symptom location, root-cause location, and patch location can differ; they should not be collapsed into an unexplained “related code” link.

Three-layer project knowledge graph: engineering facts link repositories A and B through API, message, and schema contracts; project semantics records responsibilities, concepts, field mappings, and constraints; historical issues connect evidence and reusable lessons to both layers. A task can enter through any layer.

Figure 2. Engineering relationships connect repositories, semantics explains business meanings, and historical experience attaches lessons and evidence. Based on our team's three-layer design; original Chinese labels are retained.

English reading guide: Layer 1 contains repository A's functions, types, and fields; API, message, and schema contracts; and repository B's implementations, consumers, and tests. Layer 2 contains functional responsibilities and business concepts, field meanings and cross-repository mappings, and constraints, preconditions, and compatibility requirements. Layer 3 contains historical issues, evidence such as diffs and test results, and reusable lessons with triggers, risks, and scope. Relationships distinguish implementation locations, business conventions, and constraints violated or protected. Queries can follow these links in either direction.

Bidirectional arrows in Figure 2 indicate that relationships can be queried both ways. “Code implements a convention” can be traversed as “which code implements this convention,” but the semantic relationship itself is not symmetric. Similarly, a link to a historical issue means it is worth checking; it does not establish that the current issue shares its root cause.

Ontology does not need to become a fourth layer. It is expressed primarily through concepts and constraints in the semantic layer, and through distinctions among implementation, experience, and evidence in cross-layer relationships. The first layer supplies engineering anchors and the third supplies historical counterexamples; both can help revise project semantics. Our next ontology improvements aim to make those meanings and boundaries more reliable within the existing structure.

4.3 Let agents follow relationships to the knowledge they need

Mutual indexing lets a model enter through any layer. With a specific symbol, it can start from engineering facts. With only a business requirement, it can start from concepts. With a failure symptom, it can start from experience. It then chooses the next relationship according to the current question, rather than following a fixed sequence of code, semantics, and history.

Consider a simplified cross-repository example. A configuration contract says that omitting a policy field uses the default configuration, while explicitly supplying an empty list clears restrictions. After a failed request is retried, the user's selection disappears. This example illustrates the method; it is not a particular task from the localization experiment discussed later.

Starting with the field, the engineering layer can guide the agent through request parsing in repository A, the cross-repository message contract, and persistence and retry-reading paths in repository B. The semantic layer explains that “omitted” and “explicitly empty” express different intentions, and that transmission and retries must preserve the distinction. If historical experience records default-value overwriting under matching conditions, it supplies a candidate explanation worth checking first.

Agent-led coding workflow: requirements and acceptance, impact analysis and planning, and implementation and checks draw on the three-layer graph through progressive disclosure. Execution and evidence-based acceptance lead to delivery or diagnosis and return to the relevant stage.

Workflow detail. The original Chinese diagram shows graph access throughout an agent-led coding process. English guide: clarify acceptance and expose relevant concept definitions, state scope, contracts, and evidence; analyze dependencies, cross-repository paths, compatibility and related risks; implement and check changes while consulting applicable historical lessons; then verify against the agreed criteria. Unresolved failures return to the stage responsible for the issue. The graph supports decisions throughout rather than prescribing a single retrieval order.

Verification still follows. What value was saved on the first request? What value did the retry read? If the distinction was already lost at save time, inspect parsing or persistence. If it was saved correctly and changed only on retry, inspect where defaults are applied. Experience narrows the search; current code and actual observations determine the conclusion.

Tests can follow the constraint: handling of omitted, explicitly empty, and nonempty values; preservation of intent across retries; and compatibility across protocol versions. If the current failure differs from the old case, ruling it out is useful too. Record which condition failed to match and which observation refuted the old explanation, rather than saving only the final patch.

Progressive disclosure controls the amount of information. We already support expanding lessons on demand. We want to refine this into an initial view of the reason for the association, a risk summary, and applicability; then triggers and checks; finally complete diffs, conversations, and execution evidence. Disclosure depth is separate from graph layers: engineering and semantic knowledge can also be expanded progressively.

Essential preconditions must appear with the summary. If a lesson applies only to an old protocol, that version condition cannot be hidden until the deepest level. Permissions and project scope should constrain retrieval at entry. Navigating across repositories does not grant access to every repository. Traversal also needs budgets and stopping conditions. Once the agent has enough evidence to support or reject its hypothesis, it should return to the task.

This gives the graph several concrete uses: finding impact from functionality during planning, checking cross-repository contracts during implementation, deriving boundary tests from constraints and historical counterexamples, and following symptoms toward candidate mechanisms during localization. Useful navigation gives the model a reason for its next query and connects the result back to the current judgment.

4.4 Extracting correctable lessons from code, bugs, and conversations

The three-layer structure exists; semantic extraction and maintenance now need more work. We do not want one extraction prompt to compress every source into similar summaries. Source code describes current behavior. Designs describe intended behavior. Bug reports document anomalies and investigation. Conversations often contain final clarifications and rejected alternatives.

A practical approach is to locate symbols and contracts through engineering analysis, then use an LLM to propose semantic candidates around frequent misjudgments. Each candidate carries its source, object, version, and conditions, and is checked against design, implementation, tests, or domain confirmation. Two repositories both using the name Task does not establish one concept. Different names for the same business object should not automatically create unrelated nodes either.

Beyond a definition, we want a concept card to include easily confused objects, state scope, engineering mappings, key constraints, and verification entry points. A lesson should at least retain symptoms, triggers, evidence for the causal explanation, the handling method, and conditions under which it does not apply. This is a direction for more detailed data design, rather than a claim that every field is already filled automatically.

An actual internal retrospective illustrates the issue. A parent instance had finished deletion, but its logical topology table still contained records. The initial judgment treated them as stale data. Further checking established that the parent instance and child topology states had different scopes, and that logical records could not be equated with physical processes. The earlier classification as a confirmed deletion defect was withdrawn.

Like the card-query example, the fields and data had been found, but the objects or scope were incompletely represented. In the deletion case, passing a cleanup helper's safety checks does not establish that cleanup is correct for the business. Conversely, the current implementation retaining records does not prove that every version should retain them. The deletion contract must be checked first, followed by separate observations of business state, logical data, and physical resources.

A useful next step is to trace the impact of corrections. When an old conclusion is superseded, summaries, skills, and test assumptions that cite it should be marked for review. The original event need not be deleted, but must no longer guide new tasks as a confirmed rule. This requires versioned statements and dependencies, an area we want to strengthen.

Another retrospective recorded a “read but not applied” problem. A lesson about a shared management port had been retrieved, but the subsequent observer still assumed an incorrect one-to-one relationship. Retrieval logs alone cannot establish that a lesson took effect. A stable constraint should ideally map to an object mapping, a test assertion, or a pre-action check in the current task.

The use of a lesson should be traceable to the judgment, implementation, or verification it changed. A shared-port lesson, for example, should affect the resource observation model and its tests. The distinction between request acceptance and business completion should affect terminal-state checks. Turning natural-language lessons into mandatory checks also requires establishing their contractual basis and reviewing assertions. The same mistaken assumptions must not generate both the implementation and its only acceptance standard.

Start with a narrow scope. Prioritize concepts that repeatedly affect judgment, such as state, defaults, resource identity, and cross-repository compatibility. If ordinary code search suffices for a local change with a clear contract, there is no need to force the whole graph into context. Ontology maintenance should justify its cost through reduced misjudgment and rework.

5. Preliminary results and how to test further improvement

5.1 Bug localization success rose from 58% to 65%

In an internal code-bug localization experiment, adding the graph capabilities described above increased the agent's localization success rate from 58% to 65%, an increase of 7 percentage points. This is a preliminary positive result suggesting that the three-layer knowledge structure merits further validation on localization tasks.

Localization is only one subtask in the complete loop. Patch correctness, regression coverage, and environmental stability still affect final delivery. The result therefore cannot yet be translated into an overall development-efficiency gain, nor can it establish that the ontology's semantic layer accounts for all the improvement.

We need to separate several capabilities. Does the engineering graph make cross-repository code easier to find? Do semantic explanations reduce mistakes about objects and conditions? Does historical experience provide better diagnostic starting points? Does combining layers outperform any layer alone? These questions require controlled comparisons using the same model, information sources, and budget.

Information sources matter especially when comparing the graph with ordinary memory. If the graph condition receives historical tickets while ordinary retrieval can only read code, gains may reflect additional information rather than its organization. A better comparison gives both conditions the same material and asks whether relationships and applicability add value.

bug_fixed also serves two different business purposes. Retrieving an old solution when a known failure recurs reduces duplicated work. Localizing a bug absent from the graph by applying lessons from other events provides stronger evidence of transfer. These outcomes should be reported separately.

Evaluating unseen bugs requires excluding target patches, subsequent regression tests, duplicate tickets, and indirect relationships derived from them. Removing only a bug's title is insufficient: semantic layers can retain answer clues. Time-based splits and provenance tracking support valid experiments and help identify stale knowledge in production graphs.

5.2 From a localization gain to verifiable continuous improvement

Next, we want to observe both outcomes and processes. Outcomes include localization success, pre-release acceptance completion, escaped defects, and human intervention. Processes include when knowledge was found, whether conditions matched, whether implementation or tests changed, and where rework persisted. Process evidence helps diagnosis; controlled results on subsequent tasks establish improvement.

One experiment for continuous learning is to advance tasks chronologically. One group uses a frozen graph, while another incorporates only checked lessons from tasks that have already finished. Compare both on the next batch of unseen tasks and retain regression checks on older tasks. If new knowledge improves some tasks but degrades previously successful ones, those regressions must count too.

A step closer to RSI is to compare the knowledge-update process itself. For example, let a fixed extraction strategy and a new strategy process the same historical material, produce candidate graphs, and evaluate them on independent tasks. The object of improvement might be concept-splitting rules, cross-repository mapping checks, lesson-applicability filtering, or skill generation. Producing more relationships does not establish that a strategy is better.

Following EvoOntology, we favor candidate changes addressing interpretable problems: missing semantics, incorrect mappings, difficult access, or execution omissions. Specify the behavior expected to change, then compare before and after. Following Skill∞, changes to a learning strategy should be evaluated by whether they produce more useful knowledge or methods across tasks, rather than merely fixing one lesson.

The empty-value example makes three changes concrete. First, fix retry code to finish the current task. Next, capture the distinction between empty values and defaults as a conditional lesson for similar future tasks. If several lesson types omit applicability conditions, propose changing the extraction strategy so candidates must provide conditions and counterexample evidence. Evaluate that final change by whether the lessons it produces help different subsequent tasks while reducing misuse. Results can then inform the next strategy update, rather than adding another endlessly repeated reminder.

Enterprise settings also require external boundaries. Knowledge can be revised, but a learning process cannot loosen business goals or permissions on its own. An agent may identify unreliable test tooling and propose a correction, but cannot improve its score by deleting failing tests. Publishing high-impact constraints, switching versions, and rolling back should retain review mechanisms.

Costs count too. Semantic extraction, graph maintenance, and additional checks consume time, and retrieval noise can introduce mistakes. Ultimately, we must compare the end-to-end time users wait, model and tool costs, and maintenance effort, rather than accumulated execution time or knowledge-item counts alone. Demonstrating current localization benefits and demonstrating sustained improvement in learning methods are separate goals requiring separate evidence.

6. Make project understanding the starting point for the next task

Ontology clarifies business objects, relationships, and constraints, giving experience verifiable meanings and applicability. Memory stores that knowledge and its sources. The loop supplies actions and feedback. Self-improvement mechanisms use later outcomes to determine what to retain, correct, or discard. Recursion becomes relevant when the improvement process itself can be evaluated and optimized.

Our current practice introduces team memory into the development loop from completed design to pre-release testing. A three-layer graph of engineering facts, project semantics, and bug_fixed links knowledge within and across repositories. Agents can navigate from code to experience, from experience back to implementation, and use concepts and constraints to judge applicability. The 58%-to-65% localization result is an early signal; benefits for the complete loop and continuous learning still require validation.

We want to capture useful associations experienced engineers make: what code is responsible for, why it was designed that way, where it failed before, and how to check a judgment. That understanding need not be extracted all at once, but should accumulate over time and remain correctable when new evidence appears.

At the end of a loop, alongside the delivered requirement and test results, we want to retain what the team has newly learned about the project. If the next loop can reliably begin there, it avoids another round of rediscovery and repeated misjudgment. That is a concrete place to start combining ontology and RSI in internal development.

Open-source implementation reference: TencentDB Agent Memory.

Top comments (0)