*** Settings ***
Documentation    Smoke tests for tool call router
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER_SCRIPT}    robot/helper_tool_router.py

*** Test Cases ***
Detect OpenAI Format
    [Documentation]    Detect OpenAI tool call format from payload
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    detect_openai    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    detect-openai-ok

Detect Anthropic Format
    [Documentation]    Detect Anthropic tool call format from payload
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    detect_anthropic    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    detect-anthropic-ok

Detect LangChain Format
    [Documentation]    Detect LangChain tool call format from payload
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    detect_langchain    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    detect-langchain-ok

Normalize OpenAI Payload
    [Documentation]    Normalize OpenAI format tool call to internal request
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    normalize_openai    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    normalize-openai-ok

Stable ID Generation
    [Documentation]    Generate deterministic tool call IDs
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    stable_id    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    stable-id-ok

Route OpenAI Tool Call
    [Documentation]    Route an OpenAI format tool call through the router
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    route_openai    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    route-openai-ok

Route Anthropic Tool Call
    [Documentation]    Route an Anthropic format tool call through the router
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    route_anthropic    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    route-anthropic-ok

Route Error Normalisation
    [Documentation]    Tool errors are normalized into NormalizedToolCallResult
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    route_error    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    route-error-ok

Error Classification
    [Documentation]    Error messages are classified into categories
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    error_classify    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    error-classify-ok

Schema Normalization
    [Documentation]    Tool schemas are normalized for different providers
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    schema_normalize    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    schema-normalize-ok

Batch Route Tool Calls
    [Documentation]    Route multiple tool calls as a batch
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    batch_route    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    batch-route-ok

Streaming Tool Call
    [Documentation]    Route a tool call with streaming updates
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    streaming    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    streaming-ok
