Skip to content

feat: select Telegram models by OpenRouter ID - #194

Merged
QueryPlanner merged 2 commits into
mainfrom
codex/telegram-openrouter-model
Oct 23, 2026
Merged

QueryPlanner merged 2 commits into
mainfrom
codex/telegram-openrouter-model

Conversation

@QueryPlanner

@QueryPlanner QueryPlanner commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

What

Allow Telegram users to select an exact OpenRouter model with /model <author/model-id>. The next turn uses that model in the existing conversation. /model and /models show the active ID and settings without preset model buttons.

Why

The preset list limits model selection and becomes stale as OpenRouter adds or renames models. The deployment model must remain the default configured through secrets.ROOT_AGENT_MODEL.

How

  • Parse exact model commands, including Telegram bot suffixes and surrounding whitespace.
  • Preserve model variants and OpenRouter router IDs through the existing adapter.
  • Store the selection in the existing chat profile and clear explicit thinking effort when the model changes.
  • Add /model default to clear the override and inherit the deployment model; preserve the existing reasoning fallback.
  • Reject malformed IDs, missing OpenRouter configuration, and expired preset callbacks without changing preferences.
  • Finish model-setting commands before following prompts can run, including rapid updates from the same polling batch. Close queued turn coroutines when cancelled.
  • Keep chat history and session identity; retain the existing profile scope shared across a chat's topics.
  • Update command help and Telegram documentation. No dependencies or deployment secrets change.

Tests

  • uv run ruff format and uv run ruff check
  • uv run mypy .
  • uv run pytest --cov=src --cov-report=xml --cov-report=term-missing — 2,200 passed, one Docker-dependent test skipped, 100.00% coverage.
  • uv run --no-sync mkdocs build --strict
  • bash -n setup.sh entrypoint.sh and both production/development Compose configuration checks with ENV_FILE=.env.minimal.
  • Integration tests use real SQLite, ADK sessions/plugin/runtime, and the OpenRouter adapter with simulated external HTTP responses. They verify the selected outbound model, prior messages, unchanged session identity, chat isolation, default restoration, save/delivery failures, and rapid prompt arrival during a blocked preference write.
  • Hosted CI: Python lint/type/tests, documentation build, and Docker deployment-contract checks all passed. Docker validation ran in CI because no daemon is available locally.

The initial sandboxed full run could not bind localhost ports for two existing OTLP collector tests. The complete validation sequence was rerun with local network permissions. No live Telegram or paid model request was made.

- Accept exact OpenRouter IDs in Telegram model commands
- Replace preset buttons with usage and current settings
- Preserve chat history and the configured deployment default
- Test model routing, reset, isolation, and failure behavior

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T04:54:21.544524Z e07f492 Manual 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: e07f49284c

ℹ️ 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".

Comment thread src/blacki/telegram/bot.py Resolved
- Protect model-setting commands from prompt supersession
- Close queued turn coroutines when cancellation skips them
- Verify rapid prompts wait for model selection and reset
@QueryPlanner
QueryPlanner merged commit 4e10c3f into main Oct 23, 2026
3 checks passed
@QueryPlanner
QueryPlanner deleted the codex/telegram-openrouter-model branch October 23, 2026 07:00
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