Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit 3ec15bf

Browse files
authored
fix(agent): Initialize client identification headers for cody-cli (#8149)
Fixes CODY-6118 This commit initializes the client identification headers for the `cody-cli` tool. It sets the client name and version using `setClientNameVersion` from `@sourcegraph/cody-shared`. This ensures that requests from the CLI are properly identified and versioned, otherwise the command fails. ## Test plan - run agent models list and notice it giving a reply with available models instead of error
1 parent 2f5c7ea commit 3ec15bf

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

agent/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sourcegraph/cody",
3-
"version": "5.5.20",
3+
"version": "5.5.21",
44
"description": "Cody CLI is the same technology that powers Cody in the IDE but available from the command-line.",
55
"license": "Apache-2.0",
66
"repository": {

agent/src/cli/command-models.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { getClientIdentificationHeaders } from '@sourcegraph/cody-shared'
1+
import { getClientIdentificationHeaders, setClientNameVersion } from '@sourcegraph/cody-shared'
22
import { Command } from 'commander'
3+
import packageJson from '../../package.json'
34
import { AuthenticatedAccount } from './command-auth/AuthenticatedAccount'
45
import { endpointOption } from './command-auth/command-login'
56
import { accessTokenOption } from './command-auth/command-login'
7+
import { legacyCodyClientName } from './legacyCodyClientName'
68

79
interface ListModelsOptions {
810
accessToken: string
@@ -18,6 +20,14 @@ export const modelsCommand = () =>
1820
.action(async (options: ListModelsOptions) => {
1921
const [account, spinner] =
2022
await AuthenticatedAccount.fromUserSettingsOrExitProcess(options)
23+
24+
// Initialize client identification headers
25+
setClientNameVersion({
26+
newClientName: 'cody-cli',
27+
newClientVersion: packageJson.version,
28+
newClientCompletionsStreamQueryParameterName: legacyCodyClientName,
29+
})
30+
2131
const results = await fetch(`${account.serverEndpoint}/.api/llm/models`, {
2232
headers: {
2333
Authorization: `token ${account.accessToken}`,

0 commit comments

Comments
 (0)