coding-agents: gitLogIsCurrent's documentTags fallback full-text-scans the bank (q= matches original_text) and times out at 15 s on large repos
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- postgresql, python
- Domain
- ai-infra-agents, backend, databases
Research direction
Start in hindsight-integrations/coding-agents at gitLogIsCurrent() and trace its documentTags fallback and listDocuments paging. Compare the suggested source:git-log tag lookup with the current q search; the issue reports the former returns the needed tags in about 95 ms. Confirm the fallback still identifies gitlog:<repo> without fetching document bodies, then check the existing documentTags test.
Written by the indexing model from the issue text.
Description
Bug Description
In hindsight-integrations/coding-agents, gitLogIsCurrent() falls back to HindsightClient.documentTags("gitlog:<repo>") whenever the gitlog-head:<HEAD> tag lookup misses, which in an active repository is most session starts. documentTags pages GET /documents?q=gitlog:<repo>&limit=100. On the server, q is a substring search over both id and original_text ((id ILIKE '%…%' OR original_text ILIKE '%…%'), with no index on the text), so every call detoasts and scans the full text of every document in the bank.
In a bank holding a few thousand source:git documents (full diffs), that request never fits the client's 15 s timeout. The fallback then returns undefined and the session only loses the "git in sync / catching up" note, so the wait buys nothing. Meanwhile:
- the first turn waits on it (session start is awaited before the first prompt), and
- the server keeps scanning after the client gives up, so each session start costs the database seconds of full-text scanning.
Steps to Reproduce
- Use a bank with ~2,400
source:gitdocuments (~600 MB of stored diff text) plus itsgitlog:<repo>document. - Commit once, so local
HEADdiffers from the storedgitlog-head:tag. - Start a session (any harness's session-start hook).
Expected Behavior
The freshness check reads one known document's tags in well under a second.
Actual Behavior
Measured against a stock 1.3.0 server with plugin 0.9.1 (latest; main has the same code):
| Request | Result |
|---|---|
GET /documents?tags=gitlog-head:<HEAD>&tags_match=all_strict |
96–98 ms, no hit (HEAD moved) |
GET /documents?q=gitlog:<repo>&limit=100&offset=0 |
timeout at 15,012 ms, every session start |
The same q count step, run on its own in Postgres (EXPLAIN ANALYZE) |
8,442 ms; the page query repeats the scan |
GET /documents?tags=source:git-log&tags_match=all_strict&limit=100 |
94–95 ms, total=1, returns gitlog:<repo> with its tags |
GET /documents/gitlog:<repo> |
142–432 ms, 197 KB body, includes tags |
In our logs, session starts in that repository took ~20–26 s, most of it this one request.
Suggested fix
Keep the "no document body" intent of documentTags (per its test, "reads one document's tags from the id-filtered listing, not the full document"), but make the listing actually narrow server-side. Either:
- Client only: look the gitlog document up by the tag it already carries:
listDocuments?tags=source:git-log&tags_match=all_strict, then pickid === "gitlog:<repo>"(one document per repository, so a bank shared by several repositories returns only a handful). Measured above at ~95 ms. - Server: offer an exact-id filter on the document listing (for example
ids=orq_fields=id), so an id lookup is a primary-key hit and never a text scan.
(1) needs no server change, and its paging logic can stay as it is.
Version
Plugin @vectorize-io/hindsight-coding-agents 0.9.1, server 1.3.0.
- Dominant language
- Python
- Stars
- 45.2k
- Forks
- 5.9k
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vectorize-io/hindsight
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
vectorize-io/hindsight#7254 ·
-
Control Plane shows different calendar dates for the same occurrence in Constellation and TimelineOpencore
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
vectorize-io/hindsight#7240 · 1 comment ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vectorize-io/hindsight#7233 ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
vectorize-io/hindsight#7231 ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
vectorize-io/hindsight#7228 · 1 comment ·
All issues in vectorize-io/hindsight
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day