mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-09-16 14:57:15 +00:00
feat(processors): add explicitly bound plugin event processors
This commit is contained in:
@@ -335,3 +335,31 @@ class TestDescriptorValidation:
|
||||
assert descriptor.supports_streaming() is True
|
||||
assert descriptor.supports_tool_calling() is False
|
||||
assert descriptor.supports_knowledge_retrieval() is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_registry_separates_processor_kinds_with_same_plugin_component_name():
|
||||
ap = FakeApplication()
|
||||
entries = []
|
||||
for kind, prefix in [('AgentRunner', 'plugin'), ('EventProcessor', 'event_processor')]:
|
||||
entries.append(
|
||||
{
|
||||
'plugin_author': 'test',
|
||||
'plugin_name': 'both',
|
||||
'runner_name': 'default',
|
||||
'manifest': {
|
||||
'id': f'{prefix}:test/both/default',
|
||||
'name': 'default',
|
||||
'component_kind': kind,
|
||||
'label': {'en_US': kind},
|
||||
'supported_event_patterns': ['group.member_joined'],
|
||||
},
|
||||
}
|
||||
)
|
||||
ap.plugin_connector.list_agent_runners = AsyncMock(return_value=entries)
|
||||
registry = AgentRunnerRegistry(ap)
|
||||
agents = await registry.list_runners(TEST_CONTEXT)
|
||||
processors = await registry.list_runners(TEST_CONTEXT, component_kind='EventProcessor')
|
||||
assert [item.id for item in agents] == ['plugin:test/both/default']
|
||||
assert [item.id for item in processors] == ['event_processor:test/both/default']
|
||||
assert (await registry.get(TEST_CONTEXT, processors[0].id)).component_kind == 'EventProcessor'
|
||||
|
||||
@@ -428,3 +428,30 @@ async def test_runner_stats_reports_zero_success_rate_for_failed_only_runner(sto
|
||||
assert stats[0]['runner_id'] == 'runner-a'
|
||||
assert stats[0]['failed_runs'] == 1
|
||||
assert stats[0]['success_rate'] == 0.0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_processor_instance_history_filters_count_and_pages(store):
|
||||
for index, (workspace, binding) in enumerate(
|
||||
[
|
||||
('one', 'processor-a'),
|
||||
('one', 'processor-b'),
|
||||
('two', 'processor-a'),
|
||||
('one', 'processor-a'),
|
||||
]
|
||||
):
|
||||
await store.create_run(
|
||||
run_id=f'run-{index}',
|
||||
event_id=f'event-{index}',
|
||||
binding_id=binding,
|
||||
runner_id='same-component',
|
||||
workspace_id=workspace,
|
||||
)
|
||||
first, cursor, more, total = await store.list_runs(workspace_id='one', binding_id='processor-a', limit=1)
|
||||
assert (total, more) == (2, True)
|
||||
assert first[0]['run_id'] == 'run-3'
|
||||
second, _, more, total = await store.list_runs(
|
||||
workspace_id='one', binding_id='processor-a', limit=1, before_id=cursor
|
||||
)
|
||||
assert (total, more) == (2, False)
|
||||
assert second[0]['run_id'] == 'run-0'
|
||||
|
||||
Reference in New Issue
Block a user