*** Settings ***
Documentation    Integration tests for session tell real LLM actor invocation.
...
...              Verifies that ``agents session tell`` calls ``SessionWorkflow.tell()``
...              (not the stub), persists the response, and handles the no-actor
...              error case.  Uses a stub LLM actor so no real API keys are
...              required.
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment With Database Isolation
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER}    ${CURDIR}/helper_session_tell_llm.py

*** Test Cases ***
Session Tell Workflow Returns Real Response
    [Documentation]    Verify SessionWorkflow.tell() returns a real (stub) response
    ...                and persists user + assistant messages.
    [Tags]    session_tell_llm    tdd_issue    tdd_issue_5784
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    tell-persists
    ...    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-tell-persists-ok

Session Tell No Actor Raises Clear Error
    [Documentation]    Verify SessionWorkflow.tell() raises SessionActorNotConfiguredError
    ...                when no actor is configured and no --actor override is supplied.
    [Tags]    session_tell_llm    tdd_issue    tdd_issue_5784
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    tell-no-actor
    ...    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-tell-no-actor-ok

Session Tell Stream Yields Tokens
    [Documentation]    Verify SessionWorkflow.tell_stream() yields tokens from the LLM.
    [Tags]    session_tell_llm    tdd_issue    tdd_issue_5784
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    tell-stream
    ...    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-tell-stream-ok

Session Tell Actor Override Works
    [Documentation]    Verify that the actor_override parameter overrides the session actor.
    [Tags]    session_tell_llm    tdd_issue    tdd_issue_5784
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    tell-actor-override
    ...    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-tell-actor-override-ok
