Skip to content

feat: configurable reasoning effort for thinking models - #13

Open
cthellla wants to merge 3 commits into
TONresistor:mainfrom
cthellla:fix/reasoning-models
Open

cthellla wants to merge 3 commits into
TONresistor:mainfrom
cthellla:fix/reasoning-models

Conversation

@cthellla

@cthellla cthellla commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Description

Add configurable reasoning effort for thinking models (o3, DeepSeek R1, etc).

Previously reasoning was either unsupported or hardcoded to "low". This PR adds:

  • agent.reasoning_effort config field (off/low/medium/high) with schema, validation, and hot-reload
  • WebUI: reasoning effort selector next to model dropdown, auto-disables when model doesn't support reasoning
  • /reasoning admin command to view/set effort via Telegram
  • /model now shows current reasoning effort in status
  • Model catalog: reasoning flag on known thinking models for UI hints
  • Bot command menu: /reasoning registered in syncCommands()

Note: "off" skips sending reasoning params — may not work with reasoning-only models (e.g. DeepSeek R1).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

Checklist

  • I have read the Contributing Guide
  • My PR targets the main branch
  • npm run typecheck passes
  • npm run lint passes
  • npm test passes (1 pre-existing test file fails identically on upstream/main)
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (N/A — no docs changes needed)

Related Issues

N/A

cthellla added 3 commits April 2, 2026 21:36
…eamWithContext)

Reasoning models (e.g. Step 3.5 Flash, DeepSeek R1) reject requests when
reasoning params are missing. pi-ai's stream() passes options directly to
buildParams which checks options.reasoningEffort — only streamSimple()
maps options.reasoning → reasoningEffort internally.

This adds reasoningEffort: "low" to both chatWithContext and
streamWithContext when model.reasoning is true.
Add agent.reasoning_effort config (off/low/medium/high) so users can
control thinking depth for reasoning models. Previously hardcoded to "low".

- Schema: new enum field in AgentConfigSchema (default: "low")
- Backend: chatWithContext + streamWithContext read from config
- Model catalog: add reasoning flag to ModelOption for UI hints
- WebUI: reasoning effort Select next to model selector, auto-disables
  (greyed out) when current model does not support reasoning
- Select component: add disabled prop support
- /reasoning [off|low|medium|high] — view or set reasoning effort
- /model now shows current reasoning effort alongside model name
- Help text explains what reasoning levels do and which models support it
@cthellla cthellla changed the title Fix/reasoning models feat: configurable reasoning effort for thinking models Apr 3, 2026
TONresistor added a commit that referenced this pull request Jun 1, 2026
escapeFts5Query (3 sites) and bm25ToScore (2 sites) were byte-identical clones.
Centralise both in memory/search/fts-utils.ts so the FTS5 escape list — a
syntax-injection surface — has a single definition.

Closes audit finding #13.
cthellla added a commit to cthellla/teleton-agent that referenced this pull request Sep 11, 2026
@grammyjs/types goes 3.25.0 -> 5.0.0 with it, which is what actually
matters: the typed surface moves from Bot API ~9.5 to 10.3, so
sendRichMessage, sendRichMessageDraft, answerGuestQuery,
EphemeralMessageParameters, can_stop, DisabledButton,
can_send_welcome_messages and poll persistent_id all become callable
through grammy instead of raw fetch.

That lifts the "grammY has no types yet, go through raw HTTP" blocker
shared by TONresistor#13 (streaming stop button), TONresistor#14 (ephemeral group replies) and
TONresistor#16 (rich messages in bot DMs), and makes the existing raw-fetch
answerGuestQuery in bridges/bot.ts replaceable.

grammY tracks Bot API within days (1.42 shipped the day 9.6 landed,
1.46 two days after 10.3), so there is no migration away from it.

Despite two major bumps in the types package, no source change was
needed: build, typecheck and tests are unchanged (2044 pass, same 6
known failures).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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