free-claude-code/smoke/prereq/test_tools_prereq_live.py
Alishahryar1 f3a7528d49
Some checks are pending
CI / checks (push) Waiting to run
Major refactor: API, providers, messaging, and Anthropic protocol
Consolidates the incremental refactor work into a single change set: modular web tools (api/web_tools), native Anthropic request building and SSE block policy, OpenAI conversion and error handling, provider transports and rate limiting, messaging handler and tree queue, safe logging, smoke tests, and broad test coverage.
2026-04-26 03:01:14 -07:00

56 lines
1.8 KiB
Python

from __future__ import annotations
import pytest
from core.anthropic.stream_contracts import (
assert_anthropic_stream_contract,
has_tool_use,
)
from smoke.lib.config import SmokeConfig
from smoke.lib.http import collect_message_stream, message_payload
from smoke.lib.server import start_server
from smoke.lib.skips import skip_if_upstream_unavailable_events
pytestmark = [pytest.mark.live, pytest.mark.smoke_target("tools")]
def test_live_tool_use_when_configured_model_supports_tools(
smoke_config: SmokeConfig,
) -> None:
models = smoke_config.provider_models()
if not models:
pytest.skip("no configured provider model available for tool-use smoke")
provider_model = models[0]
payload = message_payload(
"Use the echo_smoke tool once with value FCC_SMOKE_TOOL.",
model="fcc-smoke-default",
max_tokens=256,
extra={
"tools": [
{
"name": "echo_smoke",
"description": "Echo a test value.",
"input_schema": {
"type": "object",
"properties": {"value": {"type": "string"}},
"required": ["value"],
},
}
],
"tool_choice": {"type": "tool", "name": "echo_smoke"},
},
)
with start_server(
smoke_config,
env_overrides={
"MODEL": provider_model.full_model,
"MESSAGING_PLATFORM": "none",
},
name="tools",
) as server:
events = collect_message_stream(server, payload, smoke_config)
skip_if_upstream_unavailable_events(events)
assert_anthropic_stream_contract(events)
assert has_tool_use(events), "model did not emit a tool_use block"