arXiv(opens in a new tab)cs.CLOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.18616

Knowledge Graphs as Files: An Agent Harness Where Tool Creation and Tool Use Co-Evolve

Yuyang Bai, Yu Wang, Yu Zhang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Searching text-rich knowledge graphs requires following relations while examining textual evidence. Predefined graph interfaces constrain what evidence agents can access, even when they write code to combine tool calls or process retrieved subgraphs. We propose direct knowledge graph interaction (DKGI), a harness in which language model agents create graph access tools directly over complete node and edge files. The agent writes Python code to follow relations, combine node sets, and select textual evidence, interleaving execution with shell search and file inspection. This lets agents process large node sets in bulk while returning selected text for the model to assess. Execution feedback guides tool creation and revision, while the evolving tools determine what evidence the agent gathers next. On benchmark datasets spanning three domains, training-free DKGI exceeds the strongest published baseline by at least 6.7 Hit@1 points on every graph, even with a minimal harness. Controlled ablations show the benefits of multi-turn programming over shell-only access and predefined graph tools, while trajectories show agents revising code to extend searches or address errors. These findings highlight the value of allowing tool creation and tool use to co-evolve during graph search. Our code and data are available at https://github.com/leopoldwhite/DKGI.

1 Introduction

Knowledge graphs (KGs) store entities and typed relations (Pan et al., 2024). In text-rich KGs, also known as semi-structured knowledge bases, nodes carry additional text information such as product pages, paper abstracts, or drug descriptions (Wu et al., 2024b). Requests over these graphs often combine relational and textual constraints. For example, to find “papers by co-authors of X on topic Y”, a large language model (LLM) agent must locate X, identify the other authors of X’s papers,

SettingPredefined graph API / retrieverWritten by the agent
coderevisionsdirect file access
1 Direct tool useToG, Graph-CoT, ARK, GRASPGraph tools✓---
2 Code over a graph interfacesemantic parsing, KG-Agent, Code-on-Graph, AvaTaRGraph tools + code✓✓(✓)-
3 Direct knowledge graph interactionFull DKGI-✓✓✓

Table 1: Graph access and agent-written code across three settings. Direct file access lets agent-written code access all node and edge files without a predefined graph API or subgraph retriever. “(✓)” indicates support in some systems. Italicized entries denote our controlled variants (§3.3).

collect their papers, and check which ones address Y. The challenge is therefore to connect evidence across records while inspecting the text that supports each candidate.

Existing methods typically access the graph through specialized interfaces. These interfaces include database query languages (Li et al., 2023; Gu et al., 2023; Luo et al., 2024a), retrievers that return reasoning paths or subgraphs (Luo et al., 2024b; He et al., 2024), and tools for entity search, node lookup, and neighbor expansion (Sun et al., 2024; Jin et al., 2024; Polonuer et al., 2026). Beyond direct tool use, some agents write code that combines predefined graph tool calls (Wu et al., 2024a; Jiang et al., 2025), while others generate code to traverse and process graph objects provided by a dedicated subgraph retriever (Ding et al., 2026). Table 1 contrasts direct tool use (Setting ①) with these forms of code-based interaction (Setting ②). Across these designs, agents have different degrees of freedom to compute over the available data. Nevertheless, access to the underlying graph remains governed by a predefined interface. Such interfaces determine how much evidence each operation

(a) Predefined graph tools

(b) Direct knowledge graph interaction (DKGI)

Figure

Figure 1: An example from the STaRK-MAG dataset (Wu et al., 2024b): “Papers on data quality enhancement algorithms affiliated with the University of the Balearic Islands”. (a) A neighbors call can only return 20 (out of 66) researchers affiliated with the university. The agent never encounters the gold paper in this run. (b) In our DKGI, tool creation and tool use co-evolve: execution feedback guides how the agent revises and extends its code, and the revised code gathers further evidence, ultimately isolating the gold paper. Bracketed numbers denote call indices.

exposes and how the agent can inspect it. Figure 1(a) illustrates this on a request for “papers on data quality enhancement algorithms affiliated with the University of the Balearic Islands”. A neighbors call returns only some of the institution’s affiliated researchers. The agent must choose which researchers’ papers to examine and make calls to check whether those papers satisfy the topic constraint. In the illustrated run, it never encounters the gold paper. Writing code to batch these calls can simplify this process, but each call still inherits the API’s limits on the evidence it returns.

To bridge this gap, we propose direct knowledge graph interaction (DKGI), a harness in which agents write and revise their own code to access text-rich KGs. Inspired by the idea of direct corpus interaction over text corpora (Li et al., 2026), we expose both textual node records and typed graph relations as files, together with the graph schema. Unlike Setting ② in Table 1, where code uses graph query languages or APIs, or operates on retrieved subgraphs, DKGI lets the agent implement graph access directly over the complete node and edge files. The agent writes Python code to follow relations, combine sets of nodes, and inspect textual attributes. It freely interleaves code execution with shell search and record inspection, refining its code as new evidence becomes available. We provide the graph files, their format description, and an execution environment. The agent constructs the graph access tools that each request needs (Setting ③ in Table 1).

On the same request, DKGI writes and revises graph access code (tool creation) and executes it to gather evidence (tool use). Execution feedback guides which access operations to create or refine. The resulting code, in turn, changes how the agent explores the graph and what evidence it obtains. Tool creation and tool use thus co-evolve: the agent develops its tools as it searches, and its evolving tools guide the subsequent search (Figure 1(b)).

We evaluate DKGI as a training-free method on the three KGs (Amazon, MAG, and Prime) from the STaRK benchmark (Wu et al., 2024b), using both the minimal Pi harness (Zechner and Pi Contributors, 2026) and the more feature-rich Codex CLI (OpenAI, 2026a). Even in Pi, our best DKGI configuration exceeds the strongest published baseline (Tao et al., 2026) by at least 6.7 Hit@1 points on every dataset. Controlled ablations examine the role of agent-written graph access code. With the backbone, harness, and budgets held fixed, shell-only access trails predefined graph tools, whereas allowing the agent to write and execute Python code improves overall Hit@1 by 6.9 points and reverses this comparison. A single Python execution recovers little of this gain, supporting the value of multi-turn interaction. Analysis of trajectories further shows that agents use execution feedback to create and refine graph access code, which in turn guides further search. Tool creation and tool use thus co-evolve during graph search.

To summarize, our contributions are:

• We introduce DKGI, a harness in which agents create and refine graph access tools directly over complete node and edge files.

• We show that training-free DKGI achieves state-of-the-art performance on the STaRK benchmark using a minimal agent harness.

• Controlled ablations and trajectory analyses show the benefits of interleaving tool creation and tool use and characterize how the two co-evolve during agent–KG interactions.

References (7)

  • author__writes__paper
  • expression present
  • expression absent
  • officially licensed NCAA →brand metal tag hardcore fan collection team →spirit NCAA metal tags
  • : 831452} -> {
  • nodes/*.jsonl
  • if x["node_id"] in ids: print(...) Comparison