Skip to content

Let the history tool search earlier turns for text - #299

Merged
lydakis merged 2 commits into
mainfrom
claude/project-thread-obvuqb
Oct 28, 2026
Merged

lydakis merged 2 commits into
mainfrom
claude/project-thread-obvuqb

Conversation

@lydakis

@lydakis lydakis commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

The first item borrowed from fx (vercel-labs/fx at 30b6bac). fx's agent can search compacted turns by text. Until now, our history tool could read a left-out turn only by its number, so a bot had to guess where something was said.

What changes

  • history takes query, and before to continue an earlier search. A search walks the bot's lineage newest first, fork-inherited turns included. With bot, it walks that agent's lineage instead.
  • Each match comes back with its turn number, its item type, and the 160 bytes of JSON text on each side of the match, in the same view history_read pages. ASCII case is ignored, as SQLite's lower() folds it.
  • A search of the caller's own history leaves out the turn it runs in, because that turn holds the search call itself.
  • A search stops at a turn boundary once it has 20 matches or has read 64 MiB of items. It then returns next_before and done: false.
  • The context note now says …to read any of them, or with query to search them for text. The tool description and docs/RUST_PROTOTYPE.md describe the search.

Daemon cost

The search runs only when a bot calls it, so nothing here is on a turn's path and no store job is added per turn. It is one reader-thread job. The chain query is ordered by depth inside the recursive CTE, so it streams from the head and stops early once it has enough matches. Each node's instr(lower(...)) check runs separately. The reading view (the picture-free form with encrypted reasoning removed) is built only for nodes that match, so a match that exists only in picture bytes or encrypted content is dropped. The 64 MiB cap bounds how long one call can hold the reader.

Tests

  • store_contract: newest-first order, several matches in one turn, the 20-match stop and next_before, continuing with before, a missing before turn, an empty query, leaving out the running turn, fork lineage, an unknown bot.
  • test_runtime: a real daemon window with omitted turns. The context note names the search, and a history call with query finds the omitted turn but not the turn it runs in.
  • cargo test --workspace and tests.test_runtime pass locally, except three SandFS tests in sonny/tests/task.rs. Those fail because this container has no FUSE.

A bot whose context left turns out could only read them by number, so it
had to guess where something was said. `history` now takes `query`
(and `before` to continue): it walks the lineage newest first, leaves out
the turn the search runs in, and lists up to 20 matches with their turn,
item type and the text around each, ignoring ASCII case. It stops at a
turn boundary after 20 matches or 64 MiB of items and names that turn as
`next_before`. The context note now mentions the search. Borrowed from
fx, whose compacted turns are searchable by text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh
@lydakis lydakis self-assigned this Oct 28, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-28T23:42:34.262789Z c349620 New commits
🔒 Security Review ✅ Completed 2026-10-28T23:47:34.483485Z c349620 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 97bf2bff79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/store/db.rs Resolved
A multiline item reads with its whitespace compacted, so a query copied
from a history page may not occur in the item as stored. The raw-item
prefilter now passes multiline items through to the view check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants