Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Global `agent.effort` (e.g. "max") is shared across the main agent and
auxiliary models (`cron_model`, memU recall/memorize). Sonnet/Haiku tiers
only advertise {low, medium, high}; forwarding "max" triggers a 400 from
CLIProxyAPI tier validation (`internal/thinking/validate.go:125`):
thinking: validation failed | provider=claude model=claude-sonnet-4-6
error=level "max" not supported, valid levels: low, medium, high
Same shape on Opus 4.6 with "xhigh" (supports max but not xhigh), and on
any auxiliary model the user configures below their main Opus 4.7.
Add `_effective_effort(value, model)` — a small table of known Claude
models with their advertised effort levels, and a step-down lookup that
caps the requested effort to the highest level the target model supports.
Unknown models pass through unchanged (backward compatible).
Preserves "max" for Opus 4.7 main agent while letting Sonnet cron/memU
calls succeed with the tier-appropriate level.
Symmetric with existing `_parse_thinking_config(value, model)` which is
already model-aware.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- `_MODEL_EFFORT_LEVELS` keys changed to substring form (`opus-4-7`, `opus-4-6`, `sonnet-4-6`) iterated against the full model name so dated Anthropic aliases like `claude-opus-4-7-20260416` resolve. Mirrors the MODEL_PRICING pattern in nerve/db/usage.py and `_model_supports_legacy_enabled_thinking` in the same file. - `_effective_effort(value, model=None)` — default matches the sibling `_parse_thinking_config(value, model=None)`. - `logger.debug` when capping happens so users can trace why a configured `effort: max` was forwarded as `high` to Sonnet. - Docstring trimmed to one line to match the sibling method style. - New `tests/test_engine.py` covering the cap table (incl. dated aliases, unknown models, None/empty model, invalid effort string). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…l dispatch Phantom \`[mcp__nerve__send_file]\` headers in Telegram fixed: the tool now actually delivers files via the bound channel, not just persists a DB record for the web frontend. - \`SEND_FILES\` channel capability + \`BaseChannel.send_file\` interface. - Telegram \`send_document\` impl (≤50 MiB cap, path/exists checks). - Web \`send_file\` no-ops since the existing \`SendFileBlock\` card already handles UI delivery. Cross-channel hardening (addresses 3 P1 findings from Codex review): - \`AgentEngine\` tracks active channel per session (\`_active_channel\` set in \`run()\`, cleared on exit) and exposes \`get_active_channel(session_id)\`. - \`ChannelRouter.send_file(session_id, file_path, channel=...)\` requires an explicit channel. Cached \`_message_context\` target is reused only when its channel matches the requested one — never to pick the destination channel. \`channel=None\` returns False unconditionally (cron / planner / notifications / web routes that don't pass a channel through \`engine.run()\` no longer leak files to a stale Telegram chat from a prior inbound message). - \`_send_file_impl\` reads \`engine.get_active_channel\` and forwards. - Path-aware workspace containment check (\`Path.relative_to\` / \`ValueError\`) replaces the bypassable \`str.startswith\` guard — closes a sibling-prefix exfiltration vector exposed by real Telegram delivery. Test coverage: 29 unit tests across router, Telegram channel, tool impl, engine accessor — including the cross-channel leakage scenarios and sibling-prefix bypass attempt. Smoke-tested end-to-end on Telegram: agent-invoked \`send_file\` on a workspace file now delivers the document to the chat.
The 50 MiB precheck was redundant — the surrounding try/except already
catches the Telegram API's "request entity too large" response and
returns False with a logged warning. The fallback message in
\`_send_file_impl\` ("File ready: ... open the web panel to download")
still fires either way.
Removing the hard-coded cap also fixes self-hosted Bot API server
deployments, which lift the per-document limit to 2 GiB.
- Drop \`TelegramChannel._DOCUMENT_SIZE_LIMIT\` + size precheck.
- Drop \`test_oversized_file_returns_false\` (covered by
\`test_send_document_failure_returns_false\` which mocks the API
rejection directly).
- Behavior unchanged on \`api.telegram.org\` for files \\<50 MiB.
Replaces the (truncated) cut at MAX_MSG_LEN with a hierarchical, fence-aware splitter. format_response is now identity; send iterates the split chunks. Adds (N/M) continuation markers and a 100ms throttle between chunks to stay inside Telegram's 1 msg/sec/chat rate limit. Closes task 2026-04-25-smart-split-длинных-telegram-сообщений-
|
xah7ep@gmail.com seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Contributor
Author
|
Wrong target repo. Reopening on neomnezia/nerve. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
(truncated)cut inTelegramChannel.format_responsewith a hierarchical, code-fence-aware splitter.format_responseis now identity; chunking happens insendvia_smart_splitso existing call sites (stream_adapter,router) keep working.(N/M)continuation markers and a 100 ms throttle between chunks to stay inside Telegram's 1 msg/sec/chat limit.Test plan
pytest tests/test_telegram_split.py— 10 unit tests pass (paragraph/line/sentence/char fallback, fence balance, language-tag reopening, regression on truncation).pytest tests/shows no regressions vs main (422 passed, 2 skipped).(N/M)chunks, no(truncated).Closes
2026-04-25-smart-split-длинных-telegram-сообщений-.