mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-09 23:36:02 +00:00
refactor agent runner orchestration boundaries
This commit is contained in:
@@ -18,6 +18,7 @@ from unittest.mock import AsyncMock, Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from langbot.pkg.agent.runner.default_config import AgentRunnerDefaultConfigService
|
||||
from langbot.pkg.agent.runner.descriptor import AgentRunnerDescriptor
|
||||
from langbot.pkg.api.http.service.model import (
|
||||
LLMModelsService,
|
||||
@@ -432,6 +433,7 @@ class TestLLMModelsServiceCreateLLMModel:
|
||||
ap.model_mgr.load_llm_model_with_provider = AsyncMock(return_value=Mock())
|
||||
ap.pipeline_service = SimpleNamespace(update_pipeline=AsyncMock())
|
||||
ap.agent_runner_registry = FakeAgentRunnerRegistry()
|
||||
ap.agent_runner_default_config_service = AgentRunnerDefaultConfigService(ap)
|
||||
|
||||
pipeline = SimpleNamespace(
|
||||
uuid='pipeline-uuid',
|
||||
|
||||
@@ -37,7 +37,7 @@ def make_runner(runner_id: str, config_schema: list[dict]):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_default_pipeline_config_uses_installed_local_agent_schema():
|
||||
async def test_default_pipeline_config_uses_first_installed_runner_schema():
|
||||
local_agent = make_runner(
|
||||
'plugin:langbot/local-agent/default',
|
||||
[
|
||||
@@ -56,11 +56,10 @@ async def test_default_pipeline_config_uses_installed_local_agent_schema():
|
||||
|
||||
config = await PipelineService(ap).get_default_pipeline_config()
|
||||
|
||||
assert config['ai']['runner']['id'] == 'plugin:langbot/local-agent/default'
|
||||
assert config['ai']['runner']['id'] == 'plugin:alice/custom-agent/default'
|
||||
assert config['ai']['runner_config'] == {
|
||||
'plugin:langbot/local-agent/default': {
|
||||
'model': {'primary': '', 'fallbacks': []},
|
||||
'prompt': [{'role': 'system', 'content': 'Hello'}],
|
||||
'plugin:alice/custom-agent/default': {
|
||||
'api-key': '',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -425,6 +425,7 @@ class TestAgentRunProxyActions:
|
||||
try:
|
||||
response = await runtime_handler.actions[PluginToRuntimeAction.INVOKE_LLM.value]({
|
||||
'run_id': run_id,
|
||||
'caller_plugin_identity': 'test/runner',
|
||||
'llm_model_uuid': 'llm_001',
|
||||
'messages': [{'role': 'user', 'content': 'hello'}],
|
||||
'funcs': [{
|
||||
@@ -489,6 +490,7 @@ class TestAgentRunProxyActions:
|
||||
try:
|
||||
stream = runtime_handler.actions[PluginToRuntimeAction.INVOKE_LLM_STREAM.value]({
|
||||
'run_id': run_id,
|
||||
'caller_plugin_identity': 'test/runner',
|
||||
'llm_model_uuid': 'llm_stream_001',
|
||||
'messages': [{'role': 'user', 'content': 'hello'}],
|
||||
'funcs': [{
|
||||
@@ -547,6 +549,7 @@ class TestAgentRunProxyActions:
|
||||
try:
|
||||
stream = runtime_handler.actions[PluginToRuntimeAction.INVOKE_LLM_STREAM.value]({
|
||||
'run_id': run_id,
|
||||
'caller_plugin_identity': 'test/runner',
|
||||
'llm_model_uuid': 'llm_stream_002',
|
||||
'messages': [{'role': 'user', 'content': 'hello'}],
|
||||
})
|
||||
@@ -582,6 +585,7 @@ class TestAgentRunProxyActions:
|
||||
try:
|
||||
response = await runtime_handler.actions[PluginToRuntimeAction.CALL_TOOL.value]({
|
||||
'run_id': run_id,
|
||||
'caller_plugin_identity': 'test/runner',
|
||||
'tool_name': 'test/search',
|
||||
'parameters': {'q': 'langbot'},
|
||||
})
|
||||
@@ -628,6 +632,7 @@ class TestAgentRunProxyActions:
|
||||
try:
|
||||
response = await runtime_handler.actions[PluginToRuntimeAction.INVOKE_RERANK.value]({
|
||||
'run_id': run_id,
|
||||
'caller_plugin_identity': 'test/runner',
|
||||
'rerank_model_uuid': 'rerank_001',
|
||||
'query': 'hello',
|
||||
'documents': ['a', 'b'],
|
||||
|
||||
@@ -424,7 +424,9 @@ class TestNativeToolLoaderSkillPaths:
|
||||
SimpleNamespace(query_id='q1', variables={PIPELINE_BOUND_SKILLS_KEY: ['demo']}),
|
||||
)
|
||||
|
||||
assert result == {'ok': True, 'content': 'demo instructions'}
|
||||
assert result['ok'] is True
|
||||
assert result['content'] == 'demo instructions'
|
||||
assert result['truncated'] is False
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_exec_in_activated_skill_mount_rewrites_command_and_refreshes(self):
|
||||
@@ -453,7 +455,7 @@ class TestNativeToolLoaderSkillPaths:
|
||||
query,
|
||||
)
|
||||
|
||||
assert result == {'ok': True}
|
||||
assert result['ok'] is True
|
||||
tool_parameters = ap.box_service.execute_tool.await_args.args[0]
|
||||
assert tool_parameters['command'] == 'python /workspace/.skills/demo/scripts/run.py'
|
||||
assert tool_parameters['workdir'] == '/workspace/.skills/demo'
|
||||
|
||||
Reference in New Issue
Block a user