Skip to content

feat: /model command to switch AI model from Telegram#66

Merged
royosherove merged 1 commit intomainfrom
feat/model-command
May 9, 2026
Merged

feat: /model command to switch AI model from Telegram#66
royosherove merged 1 commit intomainfrom
feat/model-command

Conversation

@royosherove
Copy link
Copy Markdown
Member

Switch AI model live from Telegram without SSH.

Usage:

  • /model — show current model + available options
  • /model sonnet — switch to Claude Sonnet 4.6
  • /model opus — switch to Claude Opus 4.6
  • /model haiku — switch to Claude Haiku 4.5
  • /model opus-4.7 — switch to Claude Opus 4.7

Writes to ~/.pi/agent/settings.json. Takes effect on next agent turn.
Registered in Telegram bot command menu.

Usage:
  /model         — show current model + available options
  /model sonnet  — switch to Claude Sonnet 4.6
  /model opus    — switch to Claude Opus 4.6
  /model haiku   — switch to Claude Haiku 4.5

Writes to ~/.pi/agent/settings.json (defaultProvider + defaultModel).
Takes effect on next agent turn (new sessions use new model).
Registered in Telegram bot command menu.
@royosherove royosherove merged commit ebdecfe into main May 9, 2026
1 check passed
Copy link
Copy Markdown

@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.

Reviewed commit: 3af1ca9174

ℹ️ 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 "@codex address that feedback".

}

function writeSettings(settings: Record<string, any>): void {
writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2) + "\n");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Ensure settings path exists before persisting /model changes

writeSettings writes ~/.pi/agent/settings.json directly, but /model is now registered globally in Telegram and can run on installs where ~/.pi/agent does not exist yet (for example non-Pi setups or first-run environments). In that case writeFileSync throws ENOENT, and this handler has no local error handling, so the command fails and can bubble an unhandled rejection through the message callback. Create the parent directory (or catch and report write errors) before writing.

Useful? React with 👍 / 👎.

Comment on lines +79 to +80
settings.defaultModel = target;
settings.defaultProvider = provider;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Split provider/model when accepting slash-form model input

The slash-path branch treats any input containing / as a model id, but then keeps the existing provider and stores the entire string into defaultModel. For inputs like /model amazon-bedrock/us.anthropic..., this persists defaultProvider=amazon-bedrock and defaultModel=amazon-bedrock/us..., which later gets recombined as provider/model (e.g. amazon-bedrock/amazon-bedrock/us...) in status/reporting paths and produces a malformed configured identifier. Parse provider/model explicitly when / is present instead of storing the unsplit string.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant