Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(tool-hints): deduplicate by formatted string + per-line inline display
xzq.xu049ce9baaed5
diff --git a/nanobot/channels/feishu.py b/nanobot/channels/feishu.pyindex 2441c20c5..365732595 100644--- a/nanobot/channels/feishu.py+++ b/nanobot/channels/feishu.py@@ -1379,7 +1379,9 @@ class FeishuChannel(BaseChannel):if buf and buf.card_id:if buf.tool_hint_len > 0:buf.text = buf.text[:-buf.tool_hint_len]- suffix = f"\n\n---\nπ§ {hint}"+ lines = self._format_tool_hint_lines(hint).split("\n")+ formatted = "\n".join(f"π§ {ln}" for ln in lines if ln.strip())+ suffix = f"\n\n{formatted}\n\n"buf.text += suffixbuf.tool_hint_len = len(suffix)buf.sequence += 1diff --git a/tests/channels/test_feishu_streaming.py b/tests/channels/test_feishu_streaming.pyindex 1559ef8d3..6f5fc0580 100644--- a/tests/channels/test_feishu_streaming.py+++ b/tests/channels/test_feishu_streaming.py@@ -309,7 +309,7 @@ class TestToolHintInlineStreaming:await ch.send(msg)buf = ch._stream_bufs["oc_chat1"]- assert buf.text.endswith('π§ web_fetch("https://example.com")')+ assert 'π§ web_fetch("https://example.com")' in buf.textassert buf.tool_hint_len > 0assert buf.sequence == 3ch._client.cardkit.v1.card_element.content.assert_called_once()@@ -319,7 +319,7 @@ class TestToolHintInlineStreaming:async def test_tool_hint_preserved_on_next_delta(self):"""When new delta arrives, the tool hint is kept as permanent content and delta appends after it."""ch = _make_channel()- suffix = "\n\n---\nπ§ web_fetch(\"url\")"+ suffix = "\n\nπ§ web_fetch(\"url\")\n\n"ch._stream_bufs["oc_chat1"] = _FeishuStreamBuf(text="Partial answer" + suffix,card_id="card_1", sequence=3, last_edit=0.0,@@ -376,13 +376,13 @@ class TestToolHintInlineStreaming:assert buf.text.count("$ cd /project") == 0assert buf.text.count("$ git status") == 1assert buf.text.startswith("Partial answer")- assert buf.text.endswith("π§ $ git status")+ assert "π§ $ git status" in buf.text@pytest.mark.asyncioasync def test_tool_hint_preserved_on_resuming_flush(self):"""When _resuming flushes the buffer, tool hint is kept as permanent content."""ch = _make_channel()- suffix = "\n\n---\nπ§ $ cd /project"+ suffix = "\n\nπ§ $ cd /project\n\n"ch._stream_bufs["oc_chat1"] = _FeishuStreamBuf(text="Partial answer" + suffix,card_id="card_1", sequence=2, last_edit=0.0,@@ -401,7 +401,7 @@ class TestToolHintInlineStreaming:async def test_tool_hint_preserved_on_final_stream_end(self):"""When final _stream_end closes the card, tool hint is kept in the final text."""ch = _make_channel()- suffix = "\n\n---\nπ§ web_fetch(\"url\")"+ suffix = "\n\nπ§ web_fetch(\"url\")\n\n"ch._stream_bufs["oc_chat1"] = _FeishuStreamBuf(text="Final content" + suffix,card_id="card_1", sequence=3, last_edit=0.0,