add env using the tool api stuff

This commit is contained in:
dmahan93 2026-03-03 19:51:30 -06:00
parent c8eb63f33d
commit 12d61d197f
15 changed files with 2632 additions and 21 deletions

View file

@ -4,6 +4,9 @@ import pytest
from atroposlib.envs.server_handling.managed_server import ManagedServer
from atroposlib.envs.server_handling.server_harness import ServerHarness
from atroposlib.envs.server_handling.tool_call_translator import VLLM_AVAILABLE
skip_no_vllm = pytest.mark.skipif(not VLLM_AVAILABLE, reason="vLLM not installed")
class MockTokenizer:
@ -553,6 +556,7 @@ def _setup_chat_completion(server, tokenizer, messages, output_texts, tools=None
@pytest.mark.asyncio
@skip_no_vllm
async def test_tool_call_parsing_outbound(mock_server_with_tools):
"""Model generates <tool_call> → chat_completion returns structured tool_calls."""
managed = ManagedServer(
@ -593,6 +597,7 @@ async def test_tool_call_parsing_outbound(mock_server_with_tools):
@pytest.mark.asyncio
@skip_no_vllm
async def test_tool_choice_none_skips(mock_server_with_tools):
"""tool_choice='none' returns raw text, no parsing."""
managed = ManagedServer(
@ -647,6 +652,7 @@ async def test_no_tool_parser_passes_through(mock_server_with_tools):
@pytest.mark.asyncio
@skip_no_vllm
async def test_tool_call_multi_turn_extends_node(mock_server_with_tools):
"""Multi-turn with tool calls should extend to 1 node."""
managed = ManagedServer(
@ -708,6 +714,7 @@ async def test_tool_call_multi_turn_extends_node(mock_server_with_tools):
@pytest.mark.asyncio
@skip_no_vllm
async def test_tool_call_multiple_tools_parsed(mock_server_with_tools):
"""Multiple tool calls in one response are all parsed."""
managed = ManagedServer(
@ -744,6 +751,7 @@ async def test_tool_call_multiple_tools_parsed(mock_server_with_tools):
@pytest.mark.asyncio
@skip_no_vllm
async def test_tool_call_node_masking(mock_server_with_tools):
"""Nodes have proper masking even with tool parsing active."""
managed = ManagedServer(

View file

@ -13,6 +13,9 @@ from fastapi.testclient import TestClient
from atroposlib.envs.server_handling.managed_server_proxy import create_app
from atroposlib.envs.server_handling.server_harness import ServerHarness
from atroposlib.envs.server_handling.server_manager import ServerManager
from atroposlib.envs.server_handling.tool_call_translator import VLLM_AVAILABLE
skip_no_vllm = pytest.mark.skipif(not VLLM_AVAILABLE, reason="vLLM not installed")
# ---------------------------------------------------------------------------
# Mock tokenizer (same as test_managed_server.py / test_tool_call_translator.py)
@ -304,6 +307,7 @@ class TestChatCompletions:
# ---------------------------------------------------------------------------
@skip_no_vllm
class TestToolCalls:
def test_tool_call_outbound(self, client_and_backend):
"""Model generates <tool_call> tags → response has structured tool_calls."""
@ -535,6 +539,7 @@ class TestNodes:
# ---------------------------------------------------------------------------
@skip_no_vllm
class TestMultiStepNodeHandling:
"""Test that multi-step conversations with tool calls produce exactly 1 node.

View file

@ -7,7 +7,12 @@ import json
import pytest
from atroposlib.envs.server_handling.tool_call_translator import ToolCallTranslator
from atroposlib.envs.server_handling.tool_call_translator import (
VLLM_AVAILABLE,
ToolCallTranslator,
)
pytestmark = pytest.mark.skipif(not VLLM_AVAILABLE, reason="vLLM not installed")
# ---------------------------------------------------------------------------
# Mock tokenizer (same one from test_managed_server.py)