[argus] patch #40: extract Telegram send path to _telegram_sender.py#6
Merged
Conversation
…ender.py (carry-reduction refactor) telegram.py was the fork's dominant merge tax (574 changed lines vs v2.0.0, ~80% of the v2.0.0 rebase effort). Move the argus send path (stage-emoji indicator, HTML chunked sends with retry + plain-text fallback) verbatim into argus-owned _telegram_sender.py as channel-first free functions; state stays on the channel instance and telegram.py keeps three bound-method shims. Restore upstream's superseded stream-edit helpers byte-identical as fenced, unreachable code so upstream churn there merges clean instead of modify/delete-conflicting on every sync. Zero behavior change: the pre-existing suite runs unmodified (5016 passed, same 2 pre-existing env-dependent artifacts-router failures as the baseline). New test_telegram_sender_seam.py locks the shim delegation and upstream contracts. telegram.py carry: 574 -> 251; app/channels app-code carry: 1099 -> 776. Also refresh PATCHES.md: bytedance#40 section, #9-chain files/delete-when reword, stale bytedance#39 status note (merged as f37b829), carry-ledger row + methodology note. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
FORK-REVIEW lever 1 / stability-plan item 8. Moves the argus Telegram send path (stage-emoji indicator, HTML chunked sends with retry + plain-text fallback) out of
telegram.pyinto argus-ownedbackend/app/channels/_telegram_sender.py(zero merge tax, like_telegram_format.py/_coalesce.py/_artifact_presenter.py).telegram.pykeeps three thin bound-method shims (send,_send_running_reply,_send_running_reply_safe) plus its other carried patches (bytedance#17 welcome/lock, bytedance#28 webhook).Upstream v2.0.0's superseded edit-in-place stream helpers (
_send_stream_update.._split_message, constants,_stream_messagesinit) are restored byte-identical as fenced, unreachable code so upstream churn in those regions merges clean instead of modify/delete-conflicting on every sync. The restored regions show zero diff vsv2.0.0.Design constraints (why the shape is what it is)
init_state(channel, config)from__init__) —test_telegram_send.pyreads/writesch._working_msg& friends directly._send_running_reply_safedispatches through the boundself._send_running_reply, never the module function —test_channels.py::TestTelegramProcessingOrderandtest_telegram_channel_connections.pyoverride it per instance.send_fileis byte-identical upstream and is untouched; manager.py is untouched (its [argus] patch #46: tool_search.exclude — deferral opt-out for hot MCP tools #10 hand-off seam is already minimal and tested).Zero behavior change — proof
test_artifacts_router.pyxhtml cases in both runs.test_telegram_sender_seam.py(9 tests) locks the shim delegation and the upstream contracts the sender consumes (OutboundMessage.progress_stage/is_final/chat_id,_applicationresolved at call time,Channel._on_outbound → send), so a future bad merge that resurrects upstream's send body fails loudly.make test-blocking-iogreen (21 passed); diff-scopedscan_changed_blocking_io.pyreports no new candidates.Carry impact (measured vs
v2.0.0, insertions+deletions on files existing at v2.0.0)telegram.pyapp/channels/app codePATCHES.md updated in the same commit (hard rule): new bytedance#40 section, #9-chain files/delete-when reword, carry-ledger row + methodology note, and a fix to the stale bytedance#39 status note (it still said "NOT yet on argus tip" although f37b829 merged it — the d8ef0d1 ledger rebuild was authored against 2df36c9).
CI notes
patches-ledger,backend-unit-tests,backend-blocking-io-testsshould be green.lint-backendandfrontend-unit-testsare red on pre-existing debt, unrelated to this PR.ruff checkis clean on all three changed/new files;ruff format --checkis clean on the two new files, and its single finding intelegram.pyis a pre-existing patch-refactor: refactor the prompt management mechanism bytedance/deer-flow#17 hunk also present at the current tip (left alone to keep this PR behavior/format-pure).app.channels._telegram_senderinstead ofapp.channels.telegram. No test or tooling depends on it.After merge
Pin bump in VERSIONS.md +
make deerflow-canary(live Telegram round-trip: stage emoji animates, HTML reply, indicator cleared on final) thenmake deerflow-promote.🤖 Generated with Claude Code