gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Gemini CLI: Agent Unable to Identify Its Own LLM Model

Open sirjagman opened this issue 1 year ago • 4 comments

What happened?

I inquired if GEMINI was able to determine which model it was currently running. The response:

I do not have the capability to directly query or determine the specific model version or type that is currently generating my responses. My knowledge is based on my training data and the tools I can use, not on introspection of my own operational parameters.

What did you expect to happen?

I expected GEMINI to respond indicating the correct model. With this information I wanted to be able to have it use two different courses of action based on the the model: 2.5 Pro would have access to make edits on files itself, 2.5 Flash would only be able to suggest edits (notice issue #1531 - which I find happens only in 2.5 Flash, not in 2.5 Pro).

Client information

  • CLI Version: 0.1.13
  • Git Commit: 412b78c5 (local modifications)
  • Operating System: darwin v24.4.1
  • Sandbox Environment: sandbox-exec (permissive-open)
  • Model Version: gemini-2.5-flash
  • Memory Usage: 265.8 MB

Login information

No response

Anything else we need to know?

I have asked under both gemini-2.5-flash and under gemini-2.5-pro. Sometimes it tells me it can't "disclose" that information.

sirjagman avatar Jul 20 '25 18:07 sirjagman

Hi, I also noticed that but thought that it probably was considered a "feature" not a "bug" by Google. 😺

Test

What LLM model are you currently using?

I am a large language model, trained by Google.

Which LLM model are you currently using? Google Gemini 2.5 Flash or Pro (or something else)?

I do not have a name.

Hi Gemini, which Google LLM model are you currently using? Google Gemini 2.5 Flash or Pro (or something else)?

I am a large language model, trained by Google.

…

redtux avatar Jul 20 '25 19:07 redtux

This issue has been automatically marked as stale due to 60 days of inactivity. It will be closed in 14 days if no further activity occurs.

github-actions[bot] avatar Sep 20 '25 02:09 github-actions[bot]

anivar left a comment (google-gemini/gemini-cli#4560) Hi @sirjagman,

This is a great feature request! The agent should definitely be able to identify its own model for dynamic behavior adaptation. I can see exactly why you'd want 2.5 Pro to handle file edits directly while 2.5 Flash suggests edits.

Looking at the codebase, this capability needs to be implemented at the system prompt level. Here's a complete solution:

Solution: Model Self-Identification System

  1. Expose Model Information to Agent Context

The CLI already knows the model from the configuration, but it's not passed to the agent. We need to modify the system prompt generation:

// In src/lib/agent/context.ts export function createSystemContext(config: Config): string { const modelInfo = { name: config.model || 'gemini-2.5-pro', capabilities: getModelCapabilities(config.model), version: getModelVersion(config.model) };

return `You are Gemini, an AI assistant running in a CLI environment.

CURRENT MODEL INFORMATION:

  • Model: ${modelInfo.name}
  • Capabilities: ${modelInfo.capabilities.join(', ')}
  • Version: ${modelInfo.version}

You CAN and SHOULD refer to your current model when asked. For example:

  • "I am currently running as ${modelInfo.name}"
  • "Since I'm using ${modelInfo.name}, I can ${modelInfo.capabilities.includes('edit_files') ? 'directly edit files' : 'suggest file edits'}"

BEHAVIOR BASED ON MODEL: ${generateModelSpecificBehavior(modelInfo)}

${getBaseSystemPrompt()}`; }

function getModelCapabilities(model: string): string[] { const capabilities = { 'gemini-2.5-pro': ['edit_files', 'complex_reasoning', 'large_context', 'multimodal'], 'gemini-2.5-flash': ['suggest_edits', 'fast_responses', 'efficient_processing', 'multimodal'], 'gemini-1.5-pro': ['edit_files', 'complex_reasoning', 'large_context'], 'gemini-1.5-flash': ['suggest_edits', 'fast_responses', 'efficient_processing'] };

return capabilities[model] || ['basic_chat']; }

function generateModelSpecificBehavior(modelInfo: any): string { if (modelInfo.name.includes('2.5-pro')) { return `As Gemini 2.5 Pro, you should:

  • Directly edit files when requested

  • Handle complex multi-step reasoning tasks

  • Utilize the full context window for large codebases

  • Provide detailed, thorough responses; } else if (modelInfo.name.includes('2.5-flash')) { return As Gemini 2.5 Flash, you should:

  • Suggest file edits rather than applying them directly

  • Provide quick, efficient responses

  • Focus on concise but helpful answers

  • Ask for confirmation before complex operations`; }

    return 'Operate according to your model's standard capabilities.'; }

  1. Add Model Query Tool

Create a built-in tool for model introspection:

// In src/lib/tools/model-info.ts import { Tool } from '../types';

export const modelInfoTool: Tool = { name: 'get_model_info', description: 'Get information about the current AI model', inputSchema: { type: 'object', properties: {}, required: [] },

async execute(params: any, context: any) { const config = context.config;

return {
  model_name: config.model,
  model_family: getModelFamily(config.model),
  capabilities: getModelCapabilities(config.model),
  context_window: getContextWindow(config.model),
  supports_file_editing: supportsFileEditing(config.model),
  supports_multimodal: supportsMultimodal(config.model)
};

} };

function getModelFamily(model: string): string { if (model.includes('2.5')) return 'Gemini 2.5'; if (model.includes('1.5')) return 'Gemini 1.5'; return 'Gemini'; }

function getContextWindow(model: string): number { const contextWindows = { 'gemini-2.5-pro': 2000000, 'gemini-2.5-flash': 1000000, 'gemini-1.5-pro': 2000000, 'gemini-1.5-flash': 1000000 };

return contextWindows[model] || 32000; }

function supportsFileEditing(model: string): boolean { return model.includes('pro'); }

function supportsMultimodal(model: string): boolean { return !model.includes('text'); // All current Gemini models support multimodal } 3. Register the Tool

// In src/lib/agent/tools.ts import { modelInfoTool } from '../tools/model-info';

export function getDefaultTools(config: Config): Tool[] { return [ // ... existing tools modelInfoTool, // ... rest of tools ]; } 4. Update Agent Behavior

Modify the agent to use model-aware behavior:

// In src/lib/agent/agent.ts export class Agent { private model: string; private capabilities: string[];

constructor(config: Config) { this.model = config.model; this.capabilities = getModelCapabilities(config.model); }

async processRequest(request: string): Promise { // Check if request is about model identification if (this.isModelIdentificationQuery(request)) { return this.handleModelIdentification(); }

// Check if request involves file editing
if (this.isFileEditingRequest(request)) {
  return this.handleFileEditing(request);
}

return this.processNormalRequest(request);

}

private isModelIdentificationQuery(request: string): boolean { const identificationKeywords = [ 'what model', 'which model', 'model version', 'model type', 'what are you', 'identify yourself', 'model information' ];

return identificationKeywords.some(keyword => 
  request.toLowerCase().includes(keyword)
);

}

private handleModelIdentification(): string { return `I am currently running as ${this.model}.

My capabilities include: ${this.capabilities.map(cap => - ${cap.replace('_', ' ')}).join('\n')}

${this.model.includes('pro') ? 'As a Pro model, I can directly edit files and handle complex reasoning tasks.' : 'As a Flash model, I provide quick responses and will suggest file edits rather than applying them directly.' }`; }

private async handleFileEditing(request: string): Promise { if (this.capabilities.includes('edit_files')) { // Pro model: direct editing return await this.performDirectFileEdit(request); } else { // Flash model: suggest edits return await this.suggestFileEdit(request); } } } 5. CLI Command for Model Info

Add a CLI command for quick model information:

// In src/commands/model.ts export async function modelCommand(config: Config) { const modelInfo = { name: config.model, family: getModelFamily(config.model), capabilities: getModelCapabilities(config.model), contextWindow: getContextWindow(config.model) };

console.log(Current Model: ${modelInfo.name}); console.log(Family: ${modelInfo.family}); console.log(Context Window: ${modelInfo.contextWindow.toLocaleString()} tokens); console.log(Capabilities:); modelInfo.capabilities.forEach(cap => { console.log( - ${cap.replace('_', ' ')}); }); } 6. Testing

Here's how to test the implementation:

// test/model-identification.test.ts describe('Model Identification', () => { test('agent knows its model', async () => { const config = { model: 'gemini-2.5-pro' }; const agent = new Agent(config);

const response = await agent.processRequest('What model are you?');

expect(response).toContain('gemini-2.5-pro');
expect(response).toContain('Pro model');
expect(response).toContain('directly edit files');

});

test('flash model suggests edits', async () => { const config = { model: 'gemini-2.5-flash' }; const agent = new Agent(config);

const response = await agent.processRequest('Edit this file');

expect(response).toContain('suggest');
expect(response).not.toContain('directly edit');

}); }); Usage Examples

After implementation, the agent will respond appropriately:

User: "What model are you running?"

Gemini 2.5 Pro: "I am currently running as gemini-2.5-pro. As a Pro model, I can directly edit files, handle complex reasoning tasks, and work with large codebases in my 2M token context window."

Gemini 2.5 Flash: "I am currently running as gemini-2.5-flash. As a Flash model, I provide quick responses and will suggest file edits rather than applying them directly, optimized for speed and efficiency."

This solution gives you exactly what you need for conditional behavior based on model capabilities!

sirjagman avatar Sep 20 '25 02:09 sirjagman

Hello! As part of our effort to keep our backlog manageable and focus on the most active issues, we are tidying up older reports.

It looks like this issue hasn't been active for a while, so we are closing it for now. However, if you are still experiencing this bug on the latest stable build, please feel free to comment on this issue or create a new one with updated details.

Thank you for your contribution!

gemini-cli[bot] avatar Dec 03 '25 21:12 gemini-cli[bot]