fix(gateway): preserve local profile integrations after update - #50933
fix(gateway): preserve local profile integrations after update#50933vlsdpro wants to merge 1 commit into
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying the post-handler auto-TTS context gap; current main still calls TTS after await self._message_handler(event) in gateway/platforms/base.py:4882-4995, while tools/tts_tool.py:2200-2202 reads the session platform.
Problems
- The new
med:callback dispatches a local subprocess without a callback authorization check. Existing script-backed Gmail callbacks authorize first atplugins/platforms/telegram/adapter.py:5712-5721; the proposedmed:route does not. - The token fallback would overwrite the post-compression
-1sentinel that current preflight explicitly preserves inagent/turn_context.py:401-405. The TUI intentionally leaves provider-less current occupancy unknown attui_gateway/server.py:3219-3243, rather than presenting an estimate as real usage. - HTML MEDIA support is already present:
.html/.htmare ingateway/platforms/base.py:1455-1472, andextract_media()consumes that shared extension set atgateway/platforms/base.py:3641-3658.
Suggested changes
- Split out and rework the auto-TTS context restoration with complete routing identity and targeted tests.
- Remove the named medical-reminder script bridge, or make it a generic authorized extension.
- Drop the redundant HTML and token-fallback portions.
Automated hermes-sweeper review.
| return | ||
|
|
||
| # --- Medical reminder callbacks (med:event_id:item_id) --- | ||
| if data.startswith("med:"): |
There was a problem hiding this comment.
This dispatch reaches a subprocess-backed handler without checking _is_callback_user_authorized(). The existing gt: script callback authorizes the caller before executing anything; apply the same guard before accepting med: actions.
| api_messages, tools=agent.tools or None | ||
| ) | ||
| try: | ||
| agent.context_compressor.last_prompt_tokens = approx_request_tokens |
There was a problem hiding this comment.
Do not unconditionally overwrite compressor state with an estimate here. Current preflight preserves the -1 post-compression sentinel (agent/turn_context.py:401-405), and the TUI deliberately treats absent real occupancy as unknown; this assignment defeats both contracts.
GottZ
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Summary
Two PRs are associated with this complex, but their diffs address distinct causes rather than competing implementations: #36930 adds early local-model prompt compaction and cache diagnostics, while #50933 combines auto-TTS session-context restoration with unrelated token-accounting, HTML-media, and profile-specific Telegram callback changes.
Related pull requests
- #36930 [closed]
related— (+330/-14) — closed as superseded by #69335: the diff adds a local-endpoint/model-specific prefill guard, but misses the fully assembled pre-API path and introduces an environment override that conflicts with the config-only contract. Despite the earlier MAINTAINER-BOT keep_open verdict, the later contributor decision records that #69335 implemented the core absolute-token trigger and covered the missing pre-API path; only a per-model absolute threshold andusage.cachediagnostics remain suitable for fresh, separate follow-ups. - #50933
related— (+177/-2) — keep open with a narrowed salvage path: consistent with the keep_open review on #50933, the auto-TTS change restores the session platform around background synthesis and directly addresses the documented post-handler context gap. The remaining diff should not be retained in its current form: themed:callback lacks the repository's existing authorization check, the token fallback overwrites the preserved post-compression-1sentinel, and HTMLMEDIA:handling is already provided by the shared extension path.
Duplicates
#36930 and #50933 are not duplicates; they modify agent/conversation_loop.py and token-tracking tests for different purposes, while their primary reported causes and viable residual changes do not overlap.
Suggested consolidation
Keep #36930 closed as superseded by #69335, preserving its two residual ideas only as separate follow-ups. For #50933, author action: split out and rework the auto-TTS session-context restoration as the salvageable change; drop the already-implemented HTML test and token fallback, and move the profile-specific med: callback to a separate proposal with an explicit authorization check. No PR in this complex should be treated as a duplicate of the other.
Cross-PR triage: Reviewed 2 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 32 kB of PR diffs, 2 kB of issue/PR text, 3 kB of discussion (2 comments), 0 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.
Summary
med:callback bridge for medical reminder scripts under$HERMES_HOME/scripts/medical-reminders/.MEDIA:extraction, auto-TTS session context, and usage-less provider token fallback.Test Plan
python -m py_compile agent/conversation_loop.py gateway/platforms/base.py plugins/platforms/telegram/adapter.py tests/gateway/test_platform_base.py tests/gateway/test_tts_media_routing.py tests/run_agent/test_context_token_tracking.pypython -m pytest tests/gateway/test_tts_media_routing.py::test_auto_tts_restores_telegram_session_context_after_agent_handler tests/run_agent/test_context_token_tracking.py::test_context_counter_falls_back_to_request_estimate_when_provider_omits_usage tests/gateway/test_platform_base.py::TestExtractMedia::test_media_tag_supports_html_artifact -q -o 'addopts='python -m pytest tests/gateway/test_tts_media_routing.py tests/run_agent/test_context_token_tracking.py tests/gateway/test_platform_base.py::TestExtractMedia -q -o 'addopts='git diff --check origin/main..HEADmatches 0