fix: get model id from ApiHandler (#3512)

Not all handlers/providers use apiModelId, but they do all return a
model id from getModel().
This commit is contained in:
John Richmond 2025-05-12 14:12:11 -07:00 committed by hannesrudolph
parent 4228c8b983
commit 4d6667ba35
2 changed files with 4 additions and 5 deletions

View file

@ -69,7 +69,6 @@ describe("getEnvironmentDetails", () => {
maxOpenTabsContext: 10,
mode: "code",
customModes: [],
apiModelId: "test-model",
experiments: {},
customInstructions: "test instructions",
language: "en",
@ -102,7 +101,7 @@ describe("getEnvironmentDetails", () => {
} as unknown as RooIgnoreController,
clineMessages: [],
api: {
getModel: jest.fn().mockReturnValue({ info: { contextWindow: 100000 } }),
getModel: jest.fn().mockReturnValue({ id: "test-model", info: { contextWindow: 100000 } }),
createMessage: jest.fn(),
countTokens: jest.fn(),
} as unknown as ApiHandler,
@ -144,6 +143,7 @@ describe("getEnvironmentDetails", () => {
expect(result).toContain("# Current Context Size (Tokens)")
expect(result).toContain("# Current Cost")
expect(result).toContain("# Current Mode")
expect(result).toContain("<model>test-model</model>")
expect(mockProvider.getState).toHaveBeenCalled()

View file

@ -190,7 +190,7 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
// Add context tokens information.
const { contextTokens, totalCost } = getApiMetrics(cline.clineMessages)
const modelInfo = cline.api.getModel().info
const { id: modelId, info: modelInfo } = cline.api.getModel()
const contextWindow = modelInfo.contextWindow
const contextPercentage =
@ -203,7 +203,6 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
const {
mode,
customModes,
apiModelId,
customModePrompts,
experiments = {} as Record<ExperimentId, boolean>,
customInstructions: globalCustomInstructions,
@ -221,7 +220,7 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
details += `\n\n# Current Mode\n`
details += `<slug>${currentMode}</slug>\n`
details += `<name>${modeDetails.name}</name>\n`
details += `<model>${apiModelId}</model>\n`
details += `<model>${modelId}</model>\n`
if (Experiments.isEnabled(experiments ?? {}, EXPERIMENT_IDS.POWER_STEERING)) {
details += `<role>${modeDetails.roleDefinition}</role>\n`