refactor(channels): move tool hint rendering out of core (#6498)
* refactor(channels): move tool hint rendering out of core * test: align progress privacy check with structured tool events
This commit is contained in:
1 parent
b1cc89e922
commit
acc3750c28
30 files changed
+530
-124
No files matched your search
@@ -197,6 +197,9 @@ class LinearChannel(BaseChannel):
|
||||
key="response",
|
||||
)
|
||||
|
||||
def prepare_tool_events(self, msg: OutboundMessage) -> OutboundMessage:
|
||||
return msg
|
||||
|
||||
async def _attachment_markdown(self, msg: OutboundMessage) -> list[str]:
|
||||
client = self._client
|
||||
if client is None:
|
||||
|
||||
@@ -36,6 +36,7 @@ from nanobot.channels.linear.oauth import OAUTH_FLOWS, authorization_url
|
||||
from nanobot.channels.linear.runtime import LinearChannel
|
||||
from nanobot.channels.linear.server import LinearServerLease, acquire_http_server
|
||||
from nanobot.channels.linear.state import LinearInstallation, LinearStateStore
|
||||
from nanobot.channels.manager import ChannelManager
|
||||
|
||||
|
||||
def _config(port: int = 3979) -> LinearConfig:
|
||||
@@ -1148,7 +1149,7 @@ async def test_outbound_response_and_tool_progress_use_native_activity_shapes(
|
||||
}]
|
||||
),
|
||||
)
|
||||
await channel.send(tool)
|
||||
await ChannelManager._send_once(channel, channel.prepare_tool_events(tool))
|
||||
|
||||
assert client.activities[0]["content"] == {"type": "response", "body": "Done"}
|
||||
assert client.activities[1]["activity_id"] == activity_id
|
||||
@@ -1220,19 +1221,22 @@ async def test_tool_activities_redact_credentials_and_make_start_ephemeral(
|
||||
metadata = {
|
||||
"linear": {"organization_id": "org-1", "agent_session_id": "session-1"}
|
||||
}
|
||||
await channel.send(OutboundMessage(
|
||||
send = AsyncMock(wraps=channel.send)
|
||||
channel.send = send
|
||||
msg = OutboundMessage(
|
||||
channel="linear",
|
||||
chat_id="session-1",
|
||||
content="",
|
||||
metadata=metadata,
|
||||
event=ProgressEvent(tool_events=[{
|
||||
event=ProgressEvent(tool_hint=True, tool_events=[{
|
||||
"phase": "start",
|
||||
"call_id": "call-secret",
|
||||
"name": "call_api",
|
||||
"arguments": {"api_key": "secret-value", "query": "safe"},
|
||||
}]),
|
||||
))
|
||||
await channel.send(OutboundMessage(
|
||||
)
|
||||
await ChannelManager._send_once(channel, channel.prepare_tool_events(msg))
|
||||
msg = OutboundMessage(
|
||||
channel="linear",
|
||||
chat_id="session-1",
|
||||
content="",
|
||||
@@ -1243,8 +1247,9 @@ async def test_tool_activities_redact_credentials_and_make_start_ephemeral(
|
||||
"name": "call_api",
|
||||
"error": "Authorization: Bearer plaintext-secret",
|
||||
}]),
|
||||
))
|
||||
await channel.send(OutboundMessage(
|
||||
)
|
||||
await ChannelManager._send_once(channel, channel.prepare_tool_events(msg))
|
||||
msg = OutboundMessage(
|
||||
channel="linear",
|
||||
chat_id="session-1",
|
||||
content="",
|
||||
@@ -1256,8 +1261,11 @@ async def test_tool_activities_redact_credentials_and_make_start_ephemeral(
|
||||
"arguments": {"api_key": "secret-value"},
|
||||
"result": {"token": "result-secret", "status": "ok"},
|
||||
}]),
|
||||
))
|
||||
)
|
||||
await ChannelManager._send_once(channel, channel.prepare_tool_events(msg))
|
||||
|
||||
assert send.await_count == 3
|
||||
assert all(call.args[0].content == "" for call in send.await_args_list)
|
||||
assert client.activities[0]["ephemeral"] is True
|
||||
assert client.activities[0]["content"]["action"] == "Call API"
|
||||
assert "secret-value" not in client.activities[0]["content"]["parameter"]
|
||||
|
||||
Reference in new issue
Block a user