{"slug": "codex-title-search-is-not-transcript-search-keep-the-original-item-id", "title": "Codex title search is not transcript search: keep the original item ID", "summary": "A developer documented how Codex 0.171's thread/list searchTerm only filters extracted conversation titles, not transcript content, so finding a remembered decision requires a two-step retrieval: list threads by title to get a candidate ID, then call thread/read with includeTurns to pull the body. The writeup includes a standard-library Python script that scans agent messages and command outputs for a search phrase, handling null aggregatedOutput fields.", "body_md": "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?**\n\nThere 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.\n\nIn 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:\n\n```\n{\"id\":1,\"method\":\"thread/list\",\"params\":{\"searchTerm\":\"checkout\"}}\n```\n\nChoose a candidate ID from that catalog, or use a thread ID you already have. Then obtain the body separately:\n\n```\n{\"id\":2,\"method\":\"thread/read\",\"params\":{\"threadId\":\"synthetic-checkout-thread\",\"includeTurns\":true}}\n```\n\n[`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.\n\nSave 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.\n\nSave 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.\n\n```\n{\n  \"thread\": {\n    \"id\": \"synthetic-checkout-thread\",\n    \"sessionId\": \"synthetic-session\",\n    \"name\": \"Checkout timeout review\",\n    \"preview\": \"Review checkout timeout handling.\",\n    \"cliVersion\": \"0.171.0\",\n    \"modelProvider\": \"synthetic\",\n    \"cwd\": \"/synthetic/checkout\",\n    \"createdAt\": 1795650000,\n    \"updatedAt\": 1795650000,\n    \"ephemeral\": false,\n    \"projectId\": null,\n    \"source\": \"cli\",\n    \"status\": {\"type\": \"notLoaded\"},\n    \"turns\": [{\n      \"id\": \"synthetic-turn\", \"status\": \"completed\",\n      \"items\": [\n        {\"id\": \"synthetic-answer\", \"type\": \"agentMessage\",\n         \"text\": \"RETRY BUDGET: retain the original retry limit.\"},\n        {\"id\": \"synthetic-command\", \"type\": \"commandExecution\",\n         \"command\": \"synthetic-checkout-test\", \"commandActions\": [],\n         \"cwd\": \"/synthetic/checkout\", \"status\": \"completed\", \"exitCode\": 0,\n         \"aggregatedOutput\": \"Retry budget verified: 2 attempts retained.\"},\n        {\"id\": \"synthetic-null-output\", \"type\": \"commandExecution\",\n         \"command\": \"echo NULL-OUTPUT-MARKER\", \"commandActions\": [],\n         \"cwd\": \"/synthetic/checkout\", \"status\": \"completed\", \"exitCode\": 0,\n         \"aggregatedOutput\": null}\n      ]\n    }]\n  }\n}\n```\n\nSave this standard-library-only program as `find_answer.py`:\n\n``` python\nimport json\nimport sys\nimport unicodedata\n\ndef fold(text):\n    return unicodedata.normalize(\"NFKC\", text).casefold()\n\nwith open(sys.argv[1], encoding=\"utf-8\") as file:\n    thread = json.load(file)[\"thread\"]\nneedle = fold(sys.argv[2])\n\nfor turn in thread[\"turns\"]:\n    for item in turn[\"items\"]:\n        if item.get(\"type\") == \"agentMessage\":\n            text = item.get(\"text\") or \"\"\n        elif item.get(\"type\") == \"commandExecution\":\n            text = item.get(\"aggregatedOutput\") or \"\"\n        else:\n            continue\n        if needle and needle in fold(text):\n            print(json.dumps({\n                \"threadId\": thread[\"id\"],\n                \"turnId\": turn[\"id\"],\n                \"itemId\": item[\"id\"],\n                \"preview\": text[:200],\n            }, ensure_ascii=False))\n```\n\nRun:\n\n```\npython3 find_answer.py snapshot.json \"retry budget\"\n```\n\nOutput:\n\n```\n{\"threadId\": \"synthetic-checkout-thread\", \"turnId\": \"synthetic-turn\", \"itemId\": \"synthetic-answer\", \"preview\": \"RETRY BUDGET: retain the original retry limit.\"}\n{\"threadId\": \"synthetic-checkout-thread\", \"turnId\": \"synthetic-turn\", \"itemId\": \"synthetic-command\", \"preview\": \"Retry budget verified: 2 attempts retained.\"}\n```\n\nEach 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.\n\nThe 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.\n\nMatching 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.\n\nBoth 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.\n\nNormalization 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.\n\nThose 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.\n\nThe 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.", "url": "https://wpnews.pro/news/codex-title-search-is-not-transcript-search-keep-the-original-item-id", "canonical_source": "https://dev.to/blucca/codex-title-search-is-not-transcript-search-keep-the-original-item-id-gpg", "published_at": "2026-11-26 08:32:36+00:00", "updated_at": "2026-11-26 08:42:56.260098+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents"], "entities": ["OpenAI", "Codex"], "also_reported_by": [], "takeaway": "In Codex 0.171, thread/list searchTerm matches only the extracted thread title, so retrieve the body separately via thread/read with includeTurns and guard against null aggregatedOutput when scanning command items.", "recommendation": {"advice": "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.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/codex-title-search-is-not-transcript-search-keep-the-original-item-id", "markdown": "https://wpnews.pro/news/codex-title-search-is-not-transcript-search-keep-the-original-item-id.md", "text": "https://wpnews.pro/news/codex-title-search-is-not-transcript-search-keep-the-original-item-id.txt", "jsonld": "https://wpnews.pro/news/codex-title-search-is-not-transcript-search-keep-the-original-item-id.jsonld"}}