feat(feishu): display tool calls in code block messages

- Add special handling for tool hint messages (_tool_hint metadata)
- Send tool calls using Feishu's "code" message type with formatting
- Tool calls now appear as formatted code snippets in Feishu chat
- Add unit tests for the new functionality

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tony
2026-03-13 14:41:54 +08:00
co-authored by Claude Opus 4.6
parent 65cbd7eb78
commit df89bd2dfa
2 changed files with 125 additions and 0 deletions
+15
View File
@@ -822,6 +822,21 @@ class FeishuChannel(BaseChannel):
receive_id_type = "chat_id" if msg.chat_id.startswith("oc_") else "open_id"
loop = asyncio.get_running_loop()
# Handle tool hint messages as code blocks
if msg.metadata.get("_tool_hint"):
if msg.content and msg.content.strip():
code_content = {
"title": "Tool Call",
"code": msg.content.strip(),
"language": "text"
}
await loop.run_in_executor(
None, self._send_message_sync,
receive_id_type, msg.chat_id, "code",
json.dumps(code_content, ensure_ascii=False),
)
return
for file_path in msg.media:
if not os.path.isfile(file_path):
logger.warning("Media file not found: {}", file_path)