# Codex title search is not transcript search: keep the original item ID

> Source: <https://dev.to/blucca/codex-title-search-is-not-transcript-search-keep-the-original-item-id-gpg>
> Published: 2026-11-26 08:32:36+00:00

**Recommendation:** Treat title search as a catalog lookup only: use thread/list to get candidate IDs, then fetch transcript content with thread/read and includeTurns before searching for evidence.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

You remember a decision: “keep the retry budget at two attempts.” The conversation’s title is “Checkout timeout review.” Searching the title for `retry budget` and finding no result does not answer the question you actually asked: **where did that decision appear?**

There are two different retrieval operations here. A catalog selects conversations using metadata. A body search selects evidence inside a conversation. Treating them as interchangeable makes a useful answer look missing—and returning only the conversation title makes the answer harder to verify.

In Codex 0.171, the official [`ThreadListParams` schema](https://github.com/openai/codex/blob/ccf9be8cc458bd6b8336fe84d68d8893f2691a5e/codex-rs/app-server-protocol/schema/json/v2/ThreadListParams.json) describes `searchTerm` as an “Optional substring filter for the extracted thread title.” It is not a transcript-content parameter. A title-filter request from an initialized app-server client can look like this:

```
{"id":1,"method":"thread/list","params":{"searchTerm":"checkout"}}
```

Choose a candidate ID from that catalog, or use a thread ID you already have. Then obtain the body separately:

```
{"id":2,"method":"thread/read","params":{"threadId":"synthetic-checkout-thread","includeTurns":true}}
```

[`ThreadReadParams`](https://github.com/openai/codex/blob/ccf9be8cc458bd6b8336fe84d68d8893f2691a5e/codex-rs/app-server-protocol/schema/json/v2/ThreadReadParams.json) defines `includeTurns` as including turns and their items from rollout history. For paginated threads, that same schema prefers metadata-only reads followed by `thread/turns/list` and `thread/items/list`. This exercise consumes one supplied read result.

Save the response’s **`result` member** as `snapshot.json`; its top-level key is `thread`. The [` ThreadReadResponse` schema](https://github.com/openai/codex/blob/ccf9be8cc458bd6b8336fe84d68d8893f2691a5e/codex-rs/app-server-protocol/schema/json/v2/ThreadReadResponse.json) contains the nested thread, turn and item structures, including their IDs.

Save this complete synthetic input as `snapshot.json`. The title describes checkout work; the remembered phrase occurs in an assistant answer and a command result. A third command has no captured output.

```
{
  "thread": {
    "id": "synthetic-checkout-thread",
    "sessionId": "synthetic-session",
    "name": "Checkout timeout review",
    "preview": "Review checkout timeout handling.",
    "cliVersion": "0.171.0",
    "modelProvider": "synthetic",
    "cwd": "/synthetic/checkout",
    "createdAt": 1795650000,
    "updatedAt": 1795650000,
    "ephemeral": false,
    "projectId": null,
    "source": "cli",
    "status": {"type": "notLoaded"},
    "turns": [{
      "id": "synthetic-turn", "status": "completed",
      "items": [
        {"id": "synthetic-answer", "type": "agentMessage",
         "text": "RETRY BUDGET: retain the original retry limit."},
        {"id": "synthetic-command", "type": "commandExecution",
         "command": "synthetic-checkout-test", "commandActions": [],
         "cwd": "/synthetic/checkout", "status": "completed", "exitCode": 0,
         "aggregatedOutput": "Retry budget verified: 2 attempts retained."},
        {"id": "synthetic-null-output", "type": "commandExecution",
         "command": "echo NULL-OUTPUT-MARKER", "commandActions": [],
         "cwd": "/synthetic/checkout", "status": "completed", "exitCode": 0,
         "aggregatedOutput": null}
      ]
    }]
  }
}
```

Save this standard-library-only program as `find_answer.py`:

``` python
import json
import sys
import unicodedata

def fold(text):
    return unicodedata.normalize("NFKC", text).casefold()

with open(sys.argv[1], encoding="utf-8") as file:
    thread = json.load(file)["thread"]
needle = fold(sys.argv[2])

for turn in thread["turns"]:
    for item in turn["items"]:
        if item.get("type") == "agentMessage":
            text = item.get("text") or ""
        elif item.get("type") == "commandExecution":
            text = item.get("aggregatedOutput") or ""
        else:
            continue
        if needle and needle in fold(text):
            print(json.dumps({
                "threadId": thread["id"],
                "turnId": turn["id"],
                "itemId": item["id"],
                "preview": text[:200],
            }, ensure_ascii=False))
```

Run:

```
python3 find_answer.py snapshot.json "retry budget"
```

Output:

```
{"threadId": "synthetic-checkout-thread", "turnId": "synthetic-turn", "itemId": "synthetic-answer", "preview": "RETRY BUDGET: retain the original retry limit."}
{"threadId": "synthetic-checkout-thread", "turnId": "synthetic-turn", "itemId": "synthetic-command", "preview": "Retry budget verified: 2 attempts retained."}
```

Each matching item emits one line. Two occurrences inside one item would still emit one line; the output above identifies two different sources rather than counting phrase occurrences.

The search scope is deliberately precise: `agentMessage.text` and `commandExecution.aggregatedOutput`. The response schema describes the latter as output aggregated from stdout and stderr. A command’s shell text is a different field. Consequently, searching `NULL-OUTPUT-MARKER` produces no match: that string occurs only in the command field, whose output is null. Questions and other item kinds are outside this loop’s selected scope.

Matching text and interpreting a command’s outcome are separate steps. The fixture’s command is `completed` with `exitCode: 0`; those fields belong to the command item, not to the nearby assistant answer. Keep them attached to that item when you read the full evidence. Null output contributes an empty string to this search, so it supplies neither a phrase match nor a substitute explanation for what the command did.

Both the query and candidate text pass through NFKC normalization, then `casefold()`. Searching `ＲＥＴＲＹ ＢＵＤＧＥＴ` returns the same two IDs. Searching `.*` produces zero lines: Python’s `in` performs a literal substring comparison, not a regular-expression match. An empty query also produces no lines.

Normalization can change text length—for example, casefolding `ß` yields `ss`. The program uses normalized text only for the yes/no comparison. It never applies a transformed character offset to the original text. The IDs and preview remain unmodified; the preview is simply the first 200 original characters.

Those three IDs give you a reproducible verification path: select `thread.id`, then the matching `turn.id`, then `item.id`. Inspect the full item in the saved result or locate those same identities in a fresh history read. A preview is convenient for choosing a result; the complete source item carries the actual answer or command output.

The program reads one local JSON file and emits one line per matching item. It neither discovers every conversation nor resumes a task. This keeps the workflow small: use metadata to choose a conversation, search the selected body, and keep a precise pointer back to the evidence.
