Feedback on Cody CLI (experimental feature)

The experimental Cody CLI lets you run Cody and chat with code context from the command line.


Set the SRC_ENDPOINT and SRC_ACCESS_TOKEN environment variables:

# Sourcegraph URL ( or a URL to an enterprise instance)

# Sourcegraph access token (created in Sourcegraph > User settings > Access tokens)
export SRC_ACCESS_TOKEN=sgp_0000000000_0000000000000000000

Install it: npm install -g @sourcegraph/cody-agent

Then ask Cody a question:

$ cody-agent experimental-cli chat -m 'how do I use fetch with an AbortController?'
The `AbortController` is a modern web API that allows you to cancel ongoing asynchronous operations, such as `fetch` requests. Here's how you can use `fetch` with an `AbortController`: ...

To see all options, run cody-agent experimental-cli --help.

Code context for Cody Free/Pro users is not yet supported; see the known issues below.

Cody Enterprise users can use the Cody CLI to chat with code context from specifically named repositories:

$ cody-agent experimental-cli chat --context-repo --show-context -m 'how is authentication handled in sourcegraph/cody?'

Known issues

  • Only chat is supported, not commands or edits.
  • Context (from your local codebase) for Cody Free and Cody Pro is not yet supported but will be added soon.
    • The only reason it’s not in the initial experimental release of the Cody CLI is because it requires managing indexing processes and index data, which is more complex than just using the Cody Enterprise context that is already precomputed on the server.
  • This is only intended for human interactive usage with similar API usage patterns to in-editor usage of Cody.
    • Cody Free/Pro users: Any heavy usage (such as automated background processing) may result in your account being disabled. Please contact us with any questions.
    • Cody Enterprise users: Check with your internal Sourcegraph owner and our team for advice on using this to avoid incurring unexpected LLM fees.

Please post feedback in this thread!

Original PR #3418


Waiting eagerly to start with.

I wrote a Python wrapper around the Cody Agent for usage outside IDE. If the PR is merged, I will have a look and report feedback.

Thanks Quinn


@PriNova this could possibly help with Sublime right?

1 Like

Yes, exactly. As far as I know, Sumblime does implement the plugin packages in Python. And since I already implemented a Python wrapper around the agent binary, I’m ahead of time. The wrapper has nearly the same functionality as the agent CLI but the Enterprise features excluded.

This is the WIP repo: codypy

1 Like

@sqs If I understand it correctly, the Cody Agent works on behalf of the Cody extension or is it an independent executable?

This means, if I delete my embeddings, the Agent will automatically generate new embeddings, fetching the Cody engine if not available and uses the complete tree-sitter, or I’m wrong?

The Cody Agent is the same code/logic as what runs in the VS Code extension, and it’s already used directly by Cody for JetBrains and Neovim. However, for embeddings specifically, there is additional client-side negotiation with Cody Agent to create and use embeddings, and that is not yet implemented in this experimental CLI. We generaly find that the symf-based local search outperforms embeddings for a single codebase and is much easier to use. We haven’t documented or committed to a stable Cody Agent API yet between editors and the agent, but you can check the source for our JetBrains plugin at CodyAgent.kt - sourcegraph/jetbrains - Sourcegraph.

1 Like

Thank you for your detailed explanation.

That means, that the agent automatically downloads the symf binary if not available on client side?
And as I understand correctly, the symf binary is responsible for local search via natural language search or based on tree-sitter queries?
In contrast, this means, the client needs to know the domain terms used in the codebase, while embeddings understand higher abstractions for a client if the codebase is mostly unknown.

Thank you in advance.

@PriNova: The agent has the capability to automatically download symf, but the initial experimental release of the Cody CLI does not yet support that (no reason other than wanted to get something out sooner). I added an explanation in the known issues in the top post.

I hooked up the Cody CLI to PySheets. Here is the code I used:

And the completion works and the code it generates creates the right graph based on the shape of the dataframe I gave to Cody.

For clarity, Cody generated all the code in the top right. The bar graph was created automatically by running the auto-generated code.


@laffra That’s awesome!

1 Like