• Codex
  • Claude Code
  • VS Code
  • GitHub Copilot
  • Cursor
  • Cline
  • Windsurf
  • Google Anti-gravity
  • OpenCode
  • Pi
  • Gemini CLI
  • Hermes Agent
  • Zed
  • Junie
  • Qwen Code
  • Kiro
  • Kilo Code
  • Factory Droid

Set up GitHits for your agents

Run this command:

<> bash
npx githits@latest init

What happens next:

  1. Opens your browser to authorize GitHits
  2. Asks whether to set up GitHits at the user or project level
  3. Detects your supported AI coding tools
  4. Lets you choose which tools to configure
  5. Configures the selected tools
Back to blog

October 15, 2026 · 9 min read

Finding where a library error comes from with the GitHits API

An error message is a starting point. We tested an agent that searches the exact library version to find the file and function that produced it.

An application fails with an error from one of its libraries. You have the message and the library version, but you still need to find the code that produced it. That code can help explain whether the application passed the wrong input, encountered a library bug, or needs an upgrade.

A coding agent can inspect installed source or download the relevant release. When the report concerns an older version, finding the matching source becomes part of the investigation. An answer based on another release may point to the wrong function.

We built a small agent that searches the exact library version through the GitHits API. It reads the matching code and identifies the file and function that produced the error. We tested that step on 110 errors from GitHub issues. With source access and one retry, DeepSeek V4.1 Flash identified the right location in 89.1% of cases; Codex reached 97.6%.

Those scores measure whether the agent found the error’s location. We also asked it to suggest a cause and fix, but we didn’t score those suggestions or test the fixes.

The task

A stack trace records the sequence of function calls leading to an error. An issue report may contain just the message or an incomplete trace. We call the place in the library that creates the error its raise site. Finding it gives the agent specific code to investigate.

The agent receives the message and a package identifier written as ecosystem:package@version. This identifies the package source, its name, and the version to read. It returns the source file, the function whose body raises the message, a one-sentence cause, and a one-sentence fix.

How the agent works

The agent is about 80 lines of Python. Code runs the searches. The model reads the returned source and answers.

  1. Search the library at that exact version for the full error message with the GitHits /v1/grep endpoint. That endpoint runs a text search over the files in one version. If the full message is missing, search for its longest fixed fragments. The search skips tests, build output, dist/ directories, .d.ts declaration files, and minified files.
  2. Read short excerpts around the top matches with the GitHits /v1/read endpoint, which returns the source around a location in a file.
  3. Pass the error and those excerpts to the model in one call.
  4. Check whether the returned excerpts contain the file and function the model named. If the excerpts are empty or the answer is missing from them, ask the model for up to two new search patterns. Run those searches and let the model answer once more.

The self-check has no access to the answer key. It can catch an answer unsupported by the retrieved code, but it misses an incorrect choice among functions that do appear there. Across three runs, that happened 13 times for DeepSeek and 18 for Gemma.

Many error messages are built at runtime. The running code assembles the text from fixed words and values that change per call, so the full message is not stored in the source. missing destination name STATUS_ID in *[]models.TABLENAME is not in the sqlx source verbatim, but missing destination name is. The fragment search is there for those messages.

In an earlier version, code searched only for the full message. Gemma scored 57.6%. Adding the fragment search took it to 69.7%.

We also tried asking for three answers and choosing the one that appeared most often. This cost three times as much and changed accuracy by between -1 and +2 percentage points. Combining it with the retry gave no further improvement.

How we tested it

The final dataset contained 110 errors from GitHub issues: 37 from Python packages, 33 from npm (the JavaScript package registry), 21 from Go, and 19 from Rust. Thirty-nine messages were assembled while the program ran. We started with 111 errors and removed one after review because it came from the reporter’s application code.

We used GitHits to locate each error in the matching library release, then checked the answer key by script and by hand. An answer counted as correct when both its file and function matched the key.

We ran Gemma 4 31B, DeepSeek V4.1 Flash with reasoning off, and Codex gpt-6.1-sol at low reasoning effort, all through OpenRouter, three runs per setup. We didn’t test whether higher reasoning effort would change these results.

Accuracy and model cost

ModelWithout GitHitsGitHits, one answer attemptGitHits + retry
Gemma 4 31B9.7% ($0.04)69.7% ($0.10)83.0% ($0.16)
DeepSeek V4.1 Flash23.9% ($0.14)78.2% ($0.18)89.1% ($0.26)
Codex gpt-6.1-sol, low reasoning84.8% ($2.11)91.2% ($1.85)97.6% ($3.10)

Accuracy is the share of 110 errors with the right file and function, averaged over three runs. The first GitHits setup retrieves source and asks the model to answer once; the retry setup lets it try again when the self-check fails. The dollar figures are average model costs per 1,000 errors, excluding GitHits API fees.

The model answered errors in batches of ten. We couldn’t separate the removed error’s cost from its batch, so costs and timings come from the original runs over 111 errors.

Accuracy against model cost per 1,000 errors, on a log scale. Marker shape shows the model and color shows the setup: gray without GitHits, pink with retrieved source and one answer attempt, orange with the retry, and lighter colors for the variants that choose the most common of three answers.

DeepSeek’s retry result was the same on all three runs: 98 of 110. In the setup with one answer attempt, Codex spent 76 seconds per run in model processing, compared with 235 seconds without GitHits. Search added an average of 189 seconds per run, so the reduction in model time alone doesn’t establish a faster overall run.

When the full error message isn’t in the source

The retry helped most with messages assembled while the program runs. For example, a message may include a field name supplied by the application. Searching for that entire message can miss the library code. The model can instead suggest a fixed phrase, an error type, or a function name to search for.

There were 39 such errors. Across three runs, DeepSeek went from 60 correct answers out of 117 attempts to 96 with the retry. Codex reached the same count in the setup with one answer attempt.

Examples

The self-check fired on all 3 runs, and the retry was right every time, in these two cases:

  • gin v1.6.3 (gin-gonic/gin#2423): ["…"] is not valid value for uuid.UUID. The first search came back empty. Gemma and DeepSeek both searched a shorter fragment, such as is not valid value for, and found binding/form_mapping.go:setByForm.
  • sqlx v1.3.5 (jmoiron/sqlx#915): missing destination name STATUS_ID in *[]models.TABLENAME. The first search was empty. Searching missing destination name led both models to sqlx.go.

These errors were wrong for every model on every run without GitHits, including Codex, and right on every run with it:

  • reqwest 0.9.17 (seanmonstar/reqwest#530): a parsed Url should always be a valid Uri.
  • knex 0.15.0 (knex/knex#2753): Method implemented in the dialect driver. We tested knex 0.15.0. The issue was reported against a local knex 0.14.6, and both versions raise the error from the same dropForeign function.

On axios 1.1.3 (axios/axios#5286), maxContentLength size of …, Gemma and DeepSeek with GitHits were right on all 3 runs. Codex was right on none of the 3 runs, including with GitHits.

Results by language and package ecosystem

Accuracy by language and package ecosystem (Python, npm, Go and Rust) over three runs, for each model: gray without GitHits, pink with retrieved source and one answer attempt. This chart shows the results before the retry.

Each group has 19 to 37 errors. Here is how the retry changed the counts, as correct answers out of all attempts across three runs:

Group (errors)Gemma: first attempt → retryDeepSeek: first attempt → retryCodex: first attempt → retry
Python (37)86 → 93 /11191 → 102 /111108 → 111 /111
npm (33)72 → 79 /9980 → 86 /9980 → 91 /99
Go (21)39 → 59 /6352 → 58 /6362 → 63 /63
Rust (19)33 → 43 /5735 → 48 /5751 → 57 /57

npm packages were the hardest group for Codex, with and without the retry. Rust was the hardest for Gemma and DeepSeek. Published npm packages include compiled output, so the search skips dist/, .d.ts files, and minified files. We also count the source-repository path as a right answer when it differs from the path in the published package.

What we learned building more agents

This agent is one of about 15 specialized agents we built and measured on the GitHits API. The results followed a similar pattern across agents. GitHits raised accuracy most when the answer was a checkable fact that is hard to know from memory: an exact raise site in source, a release published after a model’s training cutoff, a security advisory, or a parameter default at a pinned version. It added little or nothing when the task was writing code, or when the API involved was widely known. In those tests, Codex scored about the same without GitHits as with it, and in one code-writing test it scored lower with GitHits (32 of 36 runs across 12 repositories, against 36 of 36 without).

Use the GitHits API

This agent uses two endpoints: /v1/grep, which searches the files of one library version, and /v1/read, which returns the source around a location in a file. In this agent, code chooses the searches and the model reads the results. The REST API is available for evaluation, with the base URL https://api.githits.dev/v1; the v1 contract is not yet finalized.

  • Get access: create an API token in the token settings of your GitHits account and send it in an Authorization: Bearer header. The authentication guide covers token storage for CI and runtime use.
  • First request: the API quickstart shows how to call an endpoint.
  • Reference: the API overview links to the v1 reference for every endpoint, where you can send test requests with your token.

If you’re building an agent workflow for debugging, book a call to discuss integrating the API.

Get started

GitHits in one command

Install GitHits or refresh an existing setup with the same command.

npx -y githits@latest init