2.1.0 (#317)
Co-authored-by: Quentin Torroba <quentin.torroba@mistral.ai> Co-authored-by: Michel Thomazo <michel.thomazo@mistral.ai> Co-authored-by: Clément Drouin <clement.drouin@mistral.ai> Co-authored-by: Vincent Guilloux <vincent.guilloux@mistral.ai> Co-authored-by: Clément Siriex <clement.sirieix@mistral.ai> Co-authored-by: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai> Co-authored-by: Nicolas Karolak <nicolas@karolak.fr>
This commit is contained in:
parent
9809cfc831
commit
51fecc67d9
176 changed files with 8652 additions and 4451 deletions
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
import pytest
|
||||
|
||||
from vibe.core.agents.models import BUILTIN_AGENTS, AgentProfile, BuiltinAgentName
|
||||
from vibe.core.config import SessionLoggingConfig, VibeConfig
|
||||
from vibe.core.config import VibeConfig
|
||||
from vibe.core.middleware import (
|
||||
PLAN_AGENT_REMINDER,
|
||||
ConversationContext,
|
||||
|
|
@ -14,16 +14,17 @@ from vibe.core.middleware import (
|
|||
from vibe.core.types import AgentStats
|
||||
|
||||
|
||||
def make_context() -> ConversationContext:
|
||||
config = VibeConfig(session_logging=SessionLoggingConfig(enabled=False))
|
||||
return ConversationContext(messages=[], stats=AgentStats(), config=config)
|
||||
@pytest.fixture
|
||||
def ctx(vibe_config: VibeConfig) -> ConversationContext:
|
||||
return ConversationContext(messages=[], stats=AgentStats(), config=vibe_config)
|
||||
|
||||
|
||||
class TestPlanAgentMiddleware:
|
||||
@pytest.mark.asyncio
|
||||
async def test_injects_reminder_when_plan_agent_active(self) -> None:
|
||||
async def test_injects_reminder_when_plan_agent_active(
|
||||
self, ctx: ConversationContext
|
||||
) -> None:
|
||||
middleware = PlanAgentMiddleware(lambda: BUILTIN_AGENTS[BuiltinAgentName.PLAN])
|
||||
ctx = make_context()
|
||||
|
||||
result = await middleware.before_turn(ctx)
|
||||
|
||||
|
|
@ -31,11 +32,12 @@ class TestPlanAgentMiddleware:
|
|||
assert result.message == PLAN_AGENT_REMINDER
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_does_not_inject_when_default_agent(self) -> None:
|
||||
async def test_does_not_inject_when_default_agent(
|
||||
self, ctx: ConversationContext
|
||||
) -> None:
|
||||
middleware = PlanAgentMiddleware(
|
||||
lambda: BUILTIN_AGENTS[BuiltinAgentName.DEFAULT]
|
||||
)
|
||||
ctx = make_context()
|
||||
|
||||
result = await middleware.before_turn(ctx)
|
||||
|
||||
|
|
@ -43,11 +45,12 @@ class TestPlanAgentMiddleware:
|
|||
assert result.message is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_does_not_inject_when_auto_approve_agent(self) -> None:
|
||||
async def test_does_not_inject_when_auto_approve_agent(
|
||||
self, ctx: ConversationContext
|
||||
) -> None:
|
||||
middleware = PlanAgentMiddleware(
|
||||
lambda: BUILTIN_AGENTS[BuiltinAgentName.AUTO_APPROVE]
|
||||
)
|
||||
ctx = make_context()
|
||||
|
||||
result = await middleware.before_turn(ctx)
|
||||
|
||||
|
|
@ -55,11 +58,12 @@ class TestPlanAgentMiddleware:
|
|||
assert result.message is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_does_not_inject_when_accept_edits_agent(self) -> None:
|
||||
async def test_does_not_inject_when_accept_edits_agent(
|
||||
self, ctx: ConversationContext
|
||||
) -> None:
|
||||
middleware = PlanAgentMiddleware(
|
||||
lambda: BUILTIN_AGENTS[BuiltinAgentName.ACCEPT_EDITS]
|
||||
)
|
||||
ctx = make_context()
|
||||
|
||||
result = await middleware.before_turn(ctx)
|
||||
|
||||
|
|
@ -67,19 +71,17 @@ class TestPlanAgentMiddleware:
|
|||
assert result.message is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_after_turn_always_continues(self) -> None:
|
||||
async def test_after_turn_always_continues(self, ctx: ConversationContext) -> None:
|
||||
middleware = PlanAgentMiddleware(lambda: BUILTIN_AGENTS[BuiltinAgentName.PLAN])
|
||||
ctx = make_context()
|
||||
|
||||
result = await middleware.after_turn(ctx)
|
||||
|
||||
assert result.action == MiddlewareAction.CONTINUE
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dynamically_checks_agent(self) -> None:
|
||||
async def test_dynamically_checks_agent(self, ctx: ConversationContext) -> None:
|
||||
current_profile: AgentProfile = BUILTIN_AGENTS[BuiltinAgentName.DEFAULT]
|
||||
middleware = PlanAgentMiddleware(lambda: current_profile)
|
||||
ctx = make_context()
|
||||
|
||||
result = await middleware.before_turn(ctx)
|
||||
assert result.action == MiddlewareAction.CONTINUE
|
||||
|
|
@ -93,12 +95,11 @@ class TestPlanAgentMiddleware:
|
|||
assert result.action == MiddlewareAction.CONTINUE
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_custom_reminder(self) -> None:
|
||||
async def test_custom_reminder(self, ctx: ConversationContext) -> None:
|
||||
custom_reminder = "Custom plan agent reminder"
|
||||
middleware = PlanAgentMiddleware(
|
||||
lambda: BUILTIN_AGENTS[BuiltinAgentName.PLAN], reminder=custom_reminder
|
||||
)
|
||||
ctx = make_context()
|
||||
|
||||
result = await middleware.before_turn(ctx)
|
||||
|
||||
|
|
@ -111,10 +112,11 @@ class TestPlanAgentMiddleware:
|
|||
|
||||
class TestMiddlewarePipelineWithPlanAgent:
|
||||
@pytest.mark.asyncio
|
||||
async def test_pipeline_includes_plan_agent_injection(self) -> None:
|
||||
async def test_pipeline_includes_plan_agent_injection(
|
||||
self, ctx: ConversationContext
|
||||
) -> None:
|
||||
pipeline = MiddlewarePipeline()
|
||||
pipeline.add(PlanAgentMiddleware(lambda: BUILTIN_AGENTS[BuiltinAgentName.PLAN]))
|
||||
ctx = make_context()
|
||||
|
||||
result = await pipeline.run_before_turn(ctx)
|
||||
|
||||
|
|
@ -122,12 +124,13 @@ class TestMiddlewarePipelineWithPlanAgent:
|
|||
assert PLAN_AGENT_REMINDER in (result.message or "")
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pipeline_skips_injection_when_not_plan_agent(self) -> None:
|
||||
async def test_pipeline_skips_injection_when_not_plan_agent(
|
||||
self, ctx: ConversationContext
|
||||
) -> None:
|
||||
pipeline = MiddlewarePipeline()
|
||||
pipeline.add(
|
||||
PlanAgentMiddleware(lambda: BUILTIN_AGENTS[BuiltinAgentName.DEFAULT])
|
||||
)
|
||||
ctx = make_context()
|
||||
|
||||
result = await pipeline.run_before_turn(ctx)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue