-
Notifications
You must be signed in to change notification settings - Fork 0
Add tool to change MEW agent model dynamically #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
| /** | ||
| * 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 | ||
| }; | ||
| } | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎.
There was a problem hiding this comment.
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 :)
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68e3a6603c7c83259e724196c528fda9