fix: align Lingma tool event lifecycle handling

Handle tool/invokeResult and richer tool/call/sync payloads in the client,
and document/retest the verified VSCode monitoring workflow for tool events.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
GitHub Actions
2026-04-19 09:49:01 +08:00
parent 1c7b86e2c0
commit 5aa7fbfae5
3 changed files with 147 additions and 25 deletions

View File

@@ -288,5 +288,52 @@ class ToolCallBridgeTests(unittest.IsolatedAsyncioTestCase):
self.assertIn("event: message_stop", body)
if __name__ == "__main__":
unittest.main()
class LingmaClientToolEventExtractionTests(unittest.TestCase):
def test_extracts_tool_event_from_results_and_parameters(self) -> None:
from app.lingma_client import LspWsRpcClient
event = LspWsRpcClient._extract_tool_event(
{
"toolCallId": "call_sync_1",
"parameters": {"path": "README.md"},
"results": [
{
"toolCallId": "call_sync_1",
"name": "read_file",
"result": {"ok": True},
}
],
}
)
self.assertEqual(
event,
{
"id": "call_sync_1",
"name": "read_file",
"input": {"path": "README.md"},
"result": {"ok": True},
},
)
def test_extracts_tool_event_from_invoke_result_payload(self) -> None:
from app.lingma_client import LspWsRpcClient
event = LspWsRpcClient._extract_tool_event(
{
"toolCallId": "call_inv_1",
"name": "search_docs",
"parameters": {"query": "gateway"},
"result": {"hits": 3},
}
)
self.assertEqual(
event,
{
"id": "call_inv_1",
"name": "search_docs",
"input": {"query": "gateway"},
"result": {"hits": 3},
},
)