Conversation
…-chat-id rate limiting Co-authored-by: soddy022 <13238069@qq.com>
…al isolation Co-authored-by: soddy022 <13238069@qq.com>
…ltiplex credential isolation
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
Fixes the
get_secret('OPENAI_API_KEY') called with no profile secret scope active while multiplexing is oncrash that kills cron jobs in multiplexed deployments (#Workstream A).Root Cause
When
multiplex_profilesis enabled,get_secret()requires an activeprofile_runtime_scope. The cron scheduler was missing this, so agent-mode cron jobs from non-default profiles crashed before generating any content (#8446d44c7a67, #c6dc075ef4b4).Changes
1.
agent/profile_scope.py(new)Shared context manager used by both the gateway inbound path and the cron scheduler — breaks the natural
gateway → cronimport cycle.2.
cron/scheduler.pyWraps
run_one_jobinprofile_runtime_scopewhen multiplexing is active. Adds helpers:_is_multiplex_active()— gate on whether to enter the scope_parse_delivery_chat_id()— extract chat_id from deliver string_resolve_target_profile_home()— 4-tier resolution (explicit path → profile name → chat_id scan → root)3.
gateway/config.pyReplaces
os.getenv("WEIXIN_TOKEN")/os.getenv("WEIXIN_ACCOUNT_ID")withget_secret()— ensures each multiplexed profile reads its own token, not the process-global env.4.
gateway/platforms/weixin.pyPer-chat-id rate limit isolation:
_rate_limit_circuit_untiland_rate_limit_eventschanged from scalar todefaultdict[str, ...]_expire_rate_limit_circuit(chat_id)self-heal method — clears expired breakers without needing a successful sendchat_idparameter5.
tests/cron/test_cron_multiplex_profile_scope.py(new)Regression tests covering profile scope resolution, credential isolation, and per-chat-id rate limiting.
Design Doc
See
docs/design/multiplexing-gateway.md(Workstream A) for architectural rationale.