fix(telemetry): avoid global plugin enumeration in workspace snapshots and support model adapters

This commit is contained in:
RockChinQ
2026-10-02 15:46:28 +00:00
parent 2e5bbc8bdd
commit 17cda1612f
4 changed files with 34 additions and 4 deletions
@@ -183,6 +183,7 @@ class TestBuildHeartbeatPayload:
assert by_workspace['workspace-b']['execution_generation'] == 9
assert by_workspace['workspace-b']['adapters'] == ['WorkspaceBAdapter']
assert 'workspace_resources' not in by_workspace['workspace-a']
ap.plugin_connector.list_plugins.assert_not_awaited()
ap.persistence_mgr.execute_async.assert_not_awaited()
ap.workspace_service.list_active_execution_bindings.assert_awaited_once()
@@ -0,0 +1,27 @@
from types import SimpleNamespace
import pytest
from pydantic import BaseModel
from langbot.pkg.telemetry.platform import observe_adapter
class ModelAdapter(BaseModel):
def get_supported_apis(self):
return ['send_message']
async def send_message(self):
return {'message_id': 'ok'}
@pytest.mark.asyncio
async def test_model_adapter_instrumentation_is_instance_local():
first, second = ModelAdapter(), ModelAdapter()
ap = SimpleNamespace(telemetry=None)
observe_adapter(ap, None, first)
wrapped = first.send_message
observe_adapter(ap, None, first)
assert first.send_message is wrapped
assert not getattr(second, '_execution_observed', False)
assert await first.send_message() == {'message_id': 'ok'}
assert await second.send_message() == {'message_id': 'ok'}