The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(feishu): pin the launch adapter's comment turn on the real scope
Teknium3366c28f47fe
diff --git a/tests/gateway/test_feishu_profile_scope_hops.py b/tests/gateway/test_feishu_profile_scope_hops.pyindex 50d09986d9b..deb2f29ee3d 100644--- a/tests/gateway/test_feishu_profile_scope_hops.py+++ b/tests/gateway/test_feishu_profile_scope_hops.py@@ -132,6 +132,45 @@ def test_drive_comment_agent_turn_binds_the_unscoped_launch_profile(tmp_path):assert seen["turn"] == ("routed", "launch-value")+def test_drive_comment_on_the_launch_adapter_reads_the_launch_env_through_the_real_scope(tmp_path, monkeypatch):+ """#139232 end to end on the real seam (no patched scope factory): the launch profile's Feishu+ callback arrives with no contextvar scope while multiplexing is on. The comment turn must read+ the launch profile's own ``.env`` credential, not raise ``UnscopedSecretError``."""+ from plugins.platforms.feishu import feishu_comment as fc+ from plugins.platforms.feishu import feishu_comment_rules as rules++ launch_home = tmp_path / "launch"+ launch_home.mkdir()+ (launch_home / ".env").write_text("FEISHU_PROBE_TOKEN=launch-env-value\n")+ monkeypatch.setenv("HERMES_HOME", str(launch_home))+ seen = {}++ def _fake_agent(prompt, client, session_key=""):+ seen["turn"] = _observe(launch_home)+ return "NO_REPLY"++ event = SimpleNamespace(event={+ "comment_id": "c1", "reply_id": "", "is_mentioned": True, "timestamp": "1",+ "notice_meta": {"file_token": "docx_t", "file_type": "docx", "notice_type": "add_reply",+ "from_user_id": {"open_id": "ou_user"}, "to_user_id": {"open_id": "ou_bot"}},+ })+ set_multiplex_active(True)+ try:+ with patch.object(rules, "load_config", return_value=object()), \+ patch.object(rules, "resolve_rule", return_value=rules.ResolvedCommentRule(True, "allowlist", frozenset(), "top")), \+ patch.object(rules, "has_wiki_keys", return_value=False), \+ patch.object(rules, "is_user_allowed", return_value=True), \+ patch.object(fc, "query_document_meta", AsyncMock(return_value={"title": "T", "url": "u"})), \+ patch.object(fc, "batch_query_comment", AsyncMock(return_value={"is_whole": False, "quote": ""})), \+ patch.object(fc, "_local_comment_prompt", AsyncMock(return_value="prompt")), \+ patch.object(fc, "_run_comment_agent", _fake_agent):+ asyncio.run(fc.handle_drive_comment_event(object(), event, self_open_id="ou_bot"))+ finally:+ set_multiplex_active(False)++ assert seen["turn"] == ("routed", "launch-env-value")++def test_ws_client_thread_and_its_loop_callbacks_carry_the_adapter_profile_scope(routed_scope, monkeypatch):"""Lark SDK callbacks run on the WS thread and re-enter the adapter loop throughrun_coroutine_threadsafe (which copies the caller's context): both must see the profile that