mirror of
https://github.com/Alishahryar1/free-claude-code.git
synced 2026-07-03 14:05:26 +02:00
fa01c2a3a6
## Summary - move provider transport families under `providers/transports/` - split OpenAI-chat transport into thin transport, stream runner, tool-call assembly, and recovery modules - split native Anthropic transport into thin transport, stream runner, recovery, and HTTP helper modules - update concrete provider imports, architecture docs, transport import contracts, version, and lockfile ## Verification - `uv run pytest tests/providers/test_streaming_errors.py tests/providers/test_openai_compat_5xx_retry.py tests/providers/test_anthropic_messages.py tests/providers/test_anthropic_messages_429_retry.py tests/providers/test_provider_transport_logging.py tests/providers/test_gemini.py tests/providers/test_nvidia_nim_request.py tests/providers/test_subagent_interception.py tests/contracts/test_import_boundaries.py` - `uv run ruff format` - `./scripts/ci.ps1`
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
import json
|
|
from unittest.mock import MagicMock
|
|
|
|
import pytest
|
|
|
|
from config.nim import NimSettings
|
|
from core.anthropic import ContentBlockManager
|
|
from providers.base import ProviderConfig
|
|
from providers.nvidia_nim import NvidiaNimProvider
|
|
from providers.transports.openai_chat.tool_calls import OpenAIToolCallAssembler
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_task_tool_interception():
|
|
# Setup provider
|
|
config = ProviderConfig(api_key="test")
|
|
provider = NvidiaNimProvider(config, nim_settings=NimSettings())
|
|
|
|
# Mock request and sse builder with real ContentBlockManager
|
|
request = MagicMock()
|
|
request.model = "test-model"
|
|
|
|
sse = MagicMock()
|
|
sse.blocks = ContentBlockManager()
|
|
|
|
# Tool call data (Task tool)
|
|
tc = {
|
|
"index": 0,
|
|
"id": "tool_123",
|
|
"function": {
|
|
"name": "Task",
|
|
"arguments": json.dumps(
|
|
{
|
|
"description": "test task",
|
|
"prompt": "do something",
|
|
"run_in_background": True,
|
|
}
|
|
),
|
|
},
|
|
}
|
|
|
|
tool_calls = OpenAIToolCallAssembler(
|
|
record_extra_content=provider._record_tool_call_extra_content
|
|
)
|
|
|
|
# Call the assembler (consume generator to trigger side effects)
|
|
list(tool_calls.process_tool_call(tc, sse))
|
|
|
|
# Find the emit_tool_delta call and check args
|
|
calls = sse.emit_tool_delta.call_args_list
|
|
assert len(calls) > 0
|
|
args_passed = json.loads(calls[0][0][1])
|
|
assert args_passed["run_in_background"] is False
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import asyncio
|
|
|
|
asyncio.run(test_task_tool_interception())
|