codex icon indicating copy to clipboard operation
codex copied to clipboard

Optional /index mode for semantic code search using OpenAI File Search

Open adsqx opened this issue 1 year ago • 1 comments

What feature would you like to see?

Feature proposal: Optional integration with OpenAI File Search

I propose considering the integration with OpenAI File Search to enable semantic code search instead of classic, iterative file scanning.
The indexing could be triggered manually, for example with a command like /index, so that the user can decide at any point whether to enable this mode or keep the current behavior.


Why this is worth considering

Currently, with large repositories:

  • each search requires sending many files to the model,
  • this generates high token usage, as large code fragments must be analyzed for every query,
  • the process is slower and less efficient.

How it could work

  • The user would have the option to run a command such as:

    /index
    

    during CLI usage to create or refresh the index.

  • After indexing, only the most relevant code fragments would be sent to the model instead of entire files.

  • Searching would then work based on meaning, not just literal names.


Benefits

  • Significantly lower token usage – typically 10×–50× less than classic iterative searching.
  • Lower search cost – embeddings are created once, and every subsequent query is cheaper and faster.
  • Semantic search – for example, it can find hash_password() when you search for "function that encrypts password".
  • Better scalability for large repositories.
  • Flexibility for the user – indexing is optional, so developers can choose between:
    • using /index for faster, cheaper semantic search, or
    • sticking to the current behavior with no indexing.

Summary

Adding an optional /index command would make Codex CLI faster, cheaper, and smarter while keeping full backward compatibility.
The search cost would be significantly lower than with classic iterative searching because, instead of sending entire files, only key fragments of code would be passed to the model.

I know this comes with some additional costs, but it would probably end up being cheaper than the tokens required for sending entire files. I think Codex would drastically improve its effectiveness, efficiency, and precision.

Are you interested in implementing this feature?

No response

Additional information

No response

adsqx avatar Sep 12 '25 00:09 adsqx

Closing in favor of #5181, which has more upvotes

etraut-openai avatar Nov 15 '25 02:11 etraut-openai