feat(agent): expose request routing metadata through my

This commit is contained in:
chengyongru
2026-07-12 00:35:17 +08:00
committed by Xubin Ren
parent d349b65713
commit 93de413432
2 changed files with 55 additions and 0 deletions
+36
View File
@@ -1133,6 +1133,42 @@ class TestLastUsageInSummary:
class TestRequestContext:
@pytest.mark.asyncio
async def test_check_exposes_current_routing_metadata_on_demand(self):
tool = _make_tool()
ctx = RequestContext(
channel="feishu",
chat_id="oc_abc123",
sender_id="ou_user456",
)
with request_context(ctx):
assert await tool.execute(action="check", key="request.channel") == (
"request.channel: 'feishu'"
)
assert await tool.execute(action="check", key="request.chat_id") == (
"request.chat_id: 'oc_abc123'"
)
assert await tool.execute(action="check", key="request.sender_id") == (
"request.sender_id: 'ou_user456'"
)
summary = await tool.execute(action="check")
assert "oc_abc123" not in summary
assert "ou_user456" not in summary
@pytest.mark.asyncio
async def test_request_routing_metadata_is_read_only(self):
tool = _make_tool()
result = await tool.execute(
action="set",
key="request.chat_id",
value="replacement",
)
assert "read-only" in result
def test_audit_reads_bound_session(self):
tool = _make_tool()
ctx = RequestContext(