Skip to content

fix(tools): read a placeholder search cursor as the first page - #197

Merged
lg2m merged 2 commits into
fix/eng-952-empty-turn-faultfrom
fix/eng-959-search-cursor
Sep 26, 2026
Merged

lg2m merged 2 commits into
fix/eng-952-empty-turn-faultfrom
fix/eng-959-search-cursor

Conversation

@lg2m

@lg2m lg2m commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Fixes ENG-959. Stacked on #196 → #195. Merge in order; each rebases to one commit.

User-visible behavior

search works on the first call again. Of 1,485 search calls in one day's sessions, ~1,470 failed with cursor_invalid. Every failure was a first call carrying a placeholder the model invented for "start from the beginning":

cursor sent count
"" 266
"initial" / "INITIAL" 44
"." 33
"0" 30
"start" / "first" 27
" ", "/", "null", misc 33

Four different models did this (gpt-5.6-sol 1,028; terra 206; gpt-6-astra 80; luna 10). Only 5 calls omitted the field and succeeded. The error text described what a valid cursor is, not that the field should be omitted, so models cycled through synonyms. One run looped on search → cursor_invalid for 1,091 turns until it overflowed its context window; it is one of the eight ENG-940 failures.

Design

None of these strings can be a real cursor (encoded cursors are base64 of path\0line with a non-empty path), so search now reads them, and whitespace, as "no cursor". A genuinely malformed cursor still errors; the message now leads with omit \cursor` for the first page. The schema's cursor` property carries a description saying the same, and the tool description says "Omit cursor for the first page". No protocol change.

Verification

  • Regression in search_pages_with_an_exact_cursor_and_caps_per_file: each placeholder returns byte-for-byte the same page as omitting the field; "!!" still fails with the new text. Fails on the base commit.
  • cargo test -p qq-core green (736). clippy -D warnings clean; fmt clean.
  • Three headless tests flaked under full-workspace load; the headless suite passes 3/3 in isolation on this branch and 2/2 on main. Pre-existing load sensitivity, unrelated to this change.

Performance

None: one trim and a string match per call.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 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 ✅ Completed 2026-09-26T19:06:12.815873Z 2b5f73f 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.

@lg2m
lg2m added this pull request to stack #203 September 26, 2026 06:44

@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: dccfa97af8

ℹ️ 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 crates/qq-core/src/tools/search.rs Resolved
Comment thread crates/qq-core/src/tools/search.rs Resolved
Comment thread crates/qq-core/src/tools/search.rs Resolved
Comment thread crates/qq-core/src/tools/specs.rs Resolved
Comment thread crates/qq-core/src/tools/search.rs Resolved
lg2m added a commit that referenced this pull request Sep 26, 2026
…e schema digest (ENG-959)

Review follow-ups on #197. The first-page placeholders are now a const
slice compared with `eq_ignore_ascii_case`, so `START`, `First`, `NULL`
read as no cursor the way `INITIAL` already did; no real cursor collides in
any casing (base64url of `path\0line` is at least four alphabet characters
decoding to a NUL). The tool-schema digest pinned by
`built_in_tool_declarations_keep_their_order_and_schema_identity` moves
with the new description text; CI on dccfa97 failed there.

Docs: `tools.md` § Read-Side Walk describes the trimmed and placeholder
cursor semantics; ledger T2.1 records the slice and the declined finding
(pre-trim length check: arguments are already capped at 64 KiB in dispatch).
Of 1,485 search calls in one day's sessions, ~1,470 failed with
cursor_invalid. Every one was a first call carrying a placeholder the model
invented for "start from the beginning": "" (266), "initial", "start",
"first", "0", ".", "/", "null". Four different models did it, the error
text said what a valid cursor looks like rather than that the field should
be omitted, and the models cycled through synonyms burning turns. One run
looped on it for 1,091 turns until it overflowed its context window.

None of these strings can be a real cursor (those are base64 of
`path\0line` with a non-empty path), so `search` now reads them, and
whitespace, as "no cursor". A genuinely malformed cursor still errors, and
the message now leads with "omit `cursor` for the first page". The schema
describes the field the same way.

Regression: each placeholder returns byte-for-byte the same page as
omitting the field; "!!" still fails with the new text.
…e schema digest (ENG-959)

Review follow-ups on #197. The first-page placeholders are now a const
slice compared with `eq_ignore_ascii_case`, so `START`, `First`, `NULL`
read as no cursor the way `INITIAL` already did; no real cursor collides in
any casing (base64url of `path\0line` is at least four alphabet characters
decoding to a NUL). The tool-schema digest pinned by
`built_in_tool_declarations_keep_their_order_and_schema_identity` moves
with the new description text; CI on dccfa97 failed there.

Docs: `tools.md` § Read-Side Walk describes the trimmed and placeholder
cursor semantics; ledger T2.1 records the slice and the declined finding
(pre-trim length check: arguments are already capped at 64 KiB in dispatch).
@lg2m
lg2m force-pushed the fix/eng-959-search-cursor branch from 0df1aa6 to 2b5f73f Compare September 26, 2026 19:03
@lg2m
lg2m merged commit c72fcbb into main Sep 26, 2026
4 checks passed
@lg2m
lg2m deleted the fix/eng-959-search-cursor branch September 26, 2026 19:04
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.

1 participant