Skip to content

Conversation

@rjcorwin
Copy link
Owner

@rjcorwin rjcorwin commented Oct 6, 2025

Summary

  • register a management tool on the MEW agent to update the OpenAI-compatible model at runtime
  • validate requests, persist the new model configuration, and log the change for observability

Testing

  • npm run build

https://chatgpt.com/codex/tasks/task_e_68e3a6603c7c83259e724196c528fda9

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines +307 to +343
/**
* Register built-in tools exposed by the agent
*/
private registerAgentTools(): void {
this.registerTool({
name: 'set_model',
description: 'Update the AI model used for reasoning and chat responses.',
inputSchema: {
type: 'object',
properties: {
model: {
type: 'string',
description: 'Identifier of the OpenAI-compatible model to use for future requests.'
}
},
required: ['model']
},
execute: async (args: any) => {
const proposedModel = typeof args?.model === 'string' ? args.model.trim() : '';

if (!proposedModel) {
throw new Error('model must be a non-empty string');
}

const previousModel = this.config.model;
this.config.model = proposedModel;

this.log('info', `🧠 Updated model via tool request: ${previousModel || 'unspecified'}${proposedModel}`);

return {
status: 'ok',
model: proposedModel,
previousModel: previousModel ?? null
};
}
});
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Hide internal set_model tool from LLM tool list

The new registerAgentTools() registers a set_model tool using registerTool, but nothing prevents this management action from being exposed to the agent’s own reasoning loop. prepareLLMTools() builds the tool list by calling getAvailableTools() and feeds every tool to the language model, and executeLLMToolCall() will execute tools owned by this participant directly. Once this commit lands, the LLM can autonomously call set_model and mutate this.config.model to arbitrary strings, leading to failed completions or unexpected cost regressions without human intent. Consider flagging internal tools so they are not advertised to the reasoning LLM or otherwise gating execution.

Useful? React with 👍 / 👎.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is soooo cursed and I love it :)

@rjcorwin rjcorwin merged commit bd10f01 into main Oct 6, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants