test_case_id: "mcp_multi_call_001"
description: "Tests an agent making two distinct calls to an MCP tool using indexed
  directives."
tags: ["all", "agent", "mcp"]
skip_intermediate_events: true

test_runner_config_overrides:
  agent_config:
    mcp_tool_response_save_threshold_bytes: 10 # Force saving for small responses

gateway_input:
  target_agent_name: "TestAgent"
  parts:
    - type: "text"
      text: "Get the user profile for 'user123' and then get their recent activity."


# The sequence of mock LLM behaviors.
llm_interactions:
  # First LLM turn: decides to get the user profile.
  - static_response:
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "call_get_profile"
                type: "function"
                function:
                  name: "get_data_stdio"
                  arguments: '{"response_to_return": {"content": [{"type": "text",
                    "text": "{\"user_id\": \"user123\", \"name\": \"Alice\", \"role\":
                    \"Admin\"}"}]}}'

  # Second LLM turn: receives the profile, then decides to get activity.
  - expected_request:
      expected_tool_responses_in_llm_messages:
        - tool_name: "get_data_stdio"
          response_json_matches:
            status: "processed_and_saved"
            message_to_llm_matches_regex: "The full response has been saved as artifact
              'get_data_stdio_json_0_.*\\.json' \\(version 0\\)\\."
            saved_mcp_response_artifact_details:
              status: "success"
              artifacts_saved:
                - data_filename_matches_regex: "get_data_stdio_json_0_.*\\.json"
                  status: "success"
    static_response:
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "call_get_activity"
                type: "function"
                function:
                  name: "get_data_stdio"
                  arguments: '{"response_to_return": {"content": [{"type": "text",
                    "text": "{\"activity\": [\"logged_in\", \"viewed_dashboard\",
                    \"ran_report\"]}"}]}}'

  # Third LLM turn: receives activity, generates final response.
  - expected_request:
      expected_tool_responses_in_llm_messages:
        - tool_name: "get_data_stdio"
          response_json_matches:
            status: "processed_and_saved"
            message_to_llm_matches_regex: "The full response has been saved as artifact
              'get_data_stdio_json_0_.*\\.json' \\(version 0\\)\\."
            saved_mcp_response_artifact_details:
              status: "success"
              artifacts_saved:
                - data_filename_matches_regex: "get_data_stdio_json_0_.*\\.json"
                  status: "success"
    static_response:
      choices:
        - message:
            role: "assistant"
            content: "User Alice (Admin) has recent activity: logged_in, viewed_dashboard,
              ran_report."

expected_gateway_output:
  - type: "final_response"
    kind: task
    id: '*'
    contextId: session_mcp_multi_call_001
    status:
      state: completed
      message:
        kind: message
        messageId: '*'
        role: agent
        parts:
          - type: "text"
            text_exact: "User Alice (Admin) has recent activity: logged_in, viewed_dashboard,
              ran_report."
