test_case_id: "mcp_multi_text_content_001"
description: "Tests that a single MCP response with multiple text items of different
  formats (JSON and CSV) creates two distinct artifacts."
tags: ["all", "agent", "mcp"]
skip_intermediate_events: true

test_runner_config_overrides:
  agent_config:
    mcp_tool_response_save_threshold_bytes: 10 # Force saving

gateway_input:
  target_agent_name: "TestAgent"
  user_identity: "mcp_multi_text_tester@example.com"
  parts:
    - type: "text"
      text: "Get a report with JSON and CSV data from the test server."
  external_context:
    a2a_session_id: "session_mcp_multi_text_001"

llm_interactions:
  - static_response:
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "call_mcp_tool_multi_text"
                type: "function"
                function:
                  name: "get_data_stdio"
                  # The MCP test server will now correctly handle a list of content blocks
                  arguments: '{"response_to_return": {"content": [{"type": "text", "text": "{\"user_id\": \"user123\", \"name\": \"Alice\"}"}, {"type": "text", "text": "id,product\\n1,widget\\n2,gadget"}]}}'

  - 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 2 artifacts,
              starting with '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"
                - data_filename_matches_regex: "get_data_stdio_csv_1_.*\\.csv"
                  status: "success"

    static_response:
      choices:
        - message:
            role: "assistant"
            content: "I have received the JSON and CSV data. Both have been saved
              as artifacts."

expected_gateway_output:
  - type: "final_response"
    kind: task
    id: '*'
    contextId: "session_mcp_multi_text_001"
    status:
      state: completed
      message:
        kind: message
        messageId: '*'
        role: agent
        parts:
          - type: "text"
            text_exact: "I have received the JSON and CSV data. Both have been saved
              as artifacts."
    assert_artifact_state:
      # Assert the JSON artifact (index 0)
      - filename_matches_regex: "get_data_stdio_json_0_.*\\.json$"
        version: 0
        expected_content_text: '{"user_id": "user123", "name": "Alice"}'
        expected_metadata_contains:
          source_tool_name: "get_data_stdio"
          content_type: "text"
          detected_format: "json"
          mime_type: "application/json"
      # Assert the CSV artifact (index 1)
      - filename_matches_regex: "get_data_stdio_csv_1_.*\\.csv$"
        version: 0
        expected_content_text: "id,product\n1,widget\n2,gadget"
        expected_metadata_contains:
          source_tool_name: "get_data_stdio"
          content_type: "text"
          detected_format: "csv"
          mime_type: "text/csv"
